Commit Graph
52 Commits
Author SHA1 Message Date
cameel a3e97108c5 [yul-phaser] main: Add GenerationalElitistWithExclusivePools as an option and make it the default 2020-03-09 13:21:48 +01:00
cameel 7e80ac861f [yul-phaser] Population: Add mutate() and crossover() methods 2020-03-09 13:21:48 +01:00
cameel 3fdb4ca607 [yul-phaser] Add geneRandomisation(), geneDeletion(), geneAddition and alternativeMutations() 2020-03-09 13:21:48 +01:00
cameel 44932dc85a [yul-phaser] Base class for pair selections 2020-03-09 13:21:48 +01:00
cameel 67fbafab8f [yul-phaser] Add RandomAlgorithm 2020-02-25 16:06:16 +01:00
cameel 4665b7a7e4 [yul-phaser] Population: Add select() method 2020-02-25 15:25:16 +01:00
cameel 83b8ab8012 [yul-phaser] Add RangeSelection, MosaicSelection and RandomSelection classes 2020-02-25 15:25:16 +01:00
cameel 3c41bfbc4e [yul-phaser] Base class for selections 2020-02-25 15:25:16 +01:00
cameel 11bdf358df [yul-phaser] Base class for genetic algorithms 2020-02-25 15:25:16 +01:00
cameel 2291cf78ac [yul-phaser] Population: Add constructors to Individual to simplify initialization 2020-02-19 17:26:34 +01:00
cameel cef01c961a [yul-phaser] Population: Keep the individuals always sorted 2020-02-19 17:26:34 +01:00
cameel 76842ac3fd [yul-phaser] Population: Evaluate fitness immediately when an individual is added or modified
- This removes the explicit evaluation phase.
- Fitness is no longer optional in Individual
2020-02-19 17:26:34 +01:00
cameel 66fdc1c374 [yul-phaser] Population: Store fitness metric rather than program directly
- In the console app use ProgramSize metric when creating the population.
2020-02-19 17:03:35 +01:00
cameel 85074e7a8a [yul-phaser] Population: Extract sorting from doSelection() into sortIndividuals() in Population class 2020-02-19 17:03:35 +01:00
cameel 41f36f421d [yul-phaser] Population: Extract conversion from chromosomes to individuals into a separate function 2020-02-19 17:03:35 +01:00
cameel 2238919c76 [yul-phaser] Add ProgramSize metric 2020-02-19 16:36:14 +01:00
cameel 096129fbc4 [yul-phaser] Base class for fitness metrics 2020-02-19 16:36:14 +01:00
cameel d9c5e2dc9f [yul-phaser] Population: Add operator+() 2020-02-18 19:40:37 +01:00
cameel 71dcbf9df5 [yul-phaser] Population: Remove ambiguous default from one of the constructors 2020-02-18 19:38:55 +01:00
cameel e4c7b73897 [yul-phaser] Store already loaded program in Population and make copies when computing fitness
- Until now the source code was being parsed during every fitness computation. Now the parsed program is reused and only the optimisation steps are applied each time.
2020-02-06 09:01:10 +01:00
cameel 57fb64d467 [yul-phaser] Make Program copyable by doing a deep copy of the AST in the copy constructor 2020-02-06 09:01:10 +01:00
cameel a189c8b6e2 [yul-phaser] Pass unique_ptr rather than a mutable reference to Program::applyOptimisationSteps()
- Giving the function ownership of an object and then receiving back another object is better than letting it implicitly modify data passed in an argument.
2020-02-06 09:01:10 +01:00
cameel 33cf4e4769 [yul-phaser] Tests for Population class 2020-02-05 18:13:30 +01:00
cameel ccaff1b08e [yul-phaser] Tests for random number generators 2020-02-05 18:13:30 +01:00
cameel 24d63a93cf [yul-phaser] Tests for Program class 2020-02-05 18:13:30 +01:00
cameel bee62cdd9e [yul-phaser] Tests for Chromosome class 2020-02-05 18:13:30 +01:00
cameel f8e397b487 [yul-phaser] Create test suite for Chromosome 2020-02-05 18:13:30 +01:00
cameel 785f65d0f5 [yul-phaser] Make Program and Population classes accept source code rather than file path
- I need some sample .yul files for testing but I see that existing tests generally have source code hard-coded in them rather than in standalone .yul files. There are lots of .yul files but they seem to be automatically processed by a special test case rather loaded ad-hoc by manually created tests.
- Program and Population required a file name until now. I'm making them accept loaded source code to be able to give them data hard-coded in a test.
2020-02-05 18:13:30 +01:00
cameel 7b7c88ae95 [yul-phaser] Add Population class 2020-02-05 18:13:30 +01:00
cameel f0fb046038 [yul-phaser] Remove Chromosome::allStepNamesExcept() 2020-02-05 18:13:30 +01:00
cameel f6d955db0b [yul-phaser] Add Chromosome class 2020-02-05 18:13:30 +01:00
cameel 57ab8922cd [yul-phaser] Add random number generators using Mersenne Twister from boost 2020-02-05 18:13:30 +01:00
cameel 21a2b69f74 [yul-phaser] Create OptimiserStepContext on demand instead of storing it in Program class
- This also lets us get rid of the static s_externallyUsedIdentifiers.
2020-02-05 18:13:30 +01:00
cameel 3baa191b94 [yul-phaser] Printing and JSON conversion for the Program class 2020-02-05 18:13:30 +01:00
cameel 2aa42b32e5 [yul-phaser] Make Program noncopyable
- Copying worked but resulted in OptimiserStepContext having a reference to NameDispenser instance of the other object.
2020-02-05 18:13:30 +01:00
cameel 14d726ff01 [yul-phaser] Program: Use unique_ptr rather than shared_ptr to hold a pointer to the AST root
- The class never shares the instance so unique_ptr makes more sense.
2020-02-05 18:13:30 +01:00
cameel 513d41c315 [yul-phaser] Add Program class 2020-02-05 18:13:30 +01:00
cameel b75370d93e [yul-phaser] Printing help and accepting input file on the command line 2020-02-05 18:13:30 +01:00
cameel e7d204383d [yul-phaser] An empty command-line application for the new tool 2020-02-05 18:13:29 +01:00
cameel c4f8df3272 Workaround for clang 5.0.0 on Ubuntu Trusty in Travis CI failing to compile a structural binding
clang fails with:

/home/travis/build/ethereum/solidity/libsolutil/CommonData.h:167:19: error: unused variable '' [-Werror,-Wunused-variable]
        for (auto const& [key, value]: originalMap)
2020-02-03 12:22:47 +01:00
cameel 5fbc4d4afa [yulopti] Automate printing of the usage banner
- This now displays internal step names rather than human-readable ones but the internal ones are readable enough and it's not something worth creating another map.
- Options in the banner are now aligned in columns and thus easier to read.
2020-02-03 12:22:47 +01:00
cameel 4129c27495 [yulopti] Replace hard-coded step list with OptimiserSuite's maps 2020-02-03 12:22:47 +01:00
cameel 4e7c1c7876 OptimiserSuite: Add two maps for converting between step names and abbreviations
- Abbreviations match those used in yulopti.
- I considered using boost::bimap but I think it would be an overkill. Two simple maps are good enough in a situation where data is constant and there isn't much of it.
- I could also use InvertibleMap from libsolutil but I don't even need any of its methods since my map is a constant. I also don't need the inverted map to store sets because my values are unique.
- The reverseMap() is generic enough to be moved to some global file with utilities but I don't sure if it's going to actually be useful to others in practice.
2020-02-03 12:22:47 +01:00
cameel 9c8187bd29 CommonData: Add invertMap() function 2020-02-03 12:06:26 +01:00
cameel ed5210490d [yulopti] Run disambiguator after VarNameCleaner
- This is a trivial change and it makes it safe to use in combination with other step.
2020-01-30 17:35:27 +01:00
cameel 2ee7e6042b OptimiserSuite: Remove VarNameCleaner from the list of available steps 2020-01-30 17:35:27 +01:00
cameel af7139c19f Enable colorized compiler output when running gcc via cmake 2020-01-30 03:11:28 +01:00
cameel 642653ea04 Make yul::Parser::parse() return unique_ptr rather than shared_ptr
- unique_ptr is more flexible and generally recommended for factory methods. It gets automatically converted to shared_ptr if necessary. Returning shared_ptr, on the other hand, forces the caller to use shared_ptr because a conversion to unique_ptr is not possible.
2020-01-29 20:07:08 +01:00
cameel d48883ca17 Fix crashes in prepare_report.py caused by using str where bytes is expected and vice-versa
1) `Popen.communicate()` expects `bytes` (a raw, binary string) if `stdout`/`stderr` are open in binary mode but is given output from `json.loads()` which is str (an abstract unicode string). Encoding the `str` object into `bytes` using UTF-8 encoding fixes that.
2) `REPORT_FILE` gets opened in binary mode which means that functions like `write()` expect `bytes`. We're giving them `str` which results in an error. Changed mode to text solves the problem.
2020-01-20 17:33:44 +01:00
cameel bf5e62931d fixup! [yulopti] Fix typo: (f)flatten -> (f)latten 2020-01-17 12:38:45 +01:00
cameel 49ca1f8534 [yulopti] Add missing ConditionalUnsimplifier to the list of available optimizations 2020-01-17 08:01:39 +01:00
cameel 4262eebdc4 [yulopti] Fix typo: (f)flatten -> (f)latten 2020-01-17 08:01:31 +01:00