fgsl / geneticalgorithm
Fgsl Genetic Algorithm
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 0
Open Issues: 0
Type:component
Requires
- php: >=7.0
- phpunit/phpunit: ^8.3
This package is auto-updated.
Last update: 2025-01-18 01:57:50 UTC
README
How to run the sample
There is a sample of genetic algorithm application as a an automated test. For running it, first run composer update
for install the dependencies, and then run:
vendor/bin/phpunit --bootstrap vendor/autoload.php tests/
An example of test output:
... Weight summatory: 1* 12 + 0 * 1 + 3 * 4 + 0 * 1 + 2 * 2 = 28 Value summatory: 1* 4 + 0 * 2 + 3 * 10 + 0 * 1 + 2 * 2 = 38 Weight summatory: 1* 12 + 2 * 1 + 0 * 4 + 1 * 1 + 0 * 2 = 15 Value summatory: 1* 4 + 2 * 2 + 0 * 10 + 1 * 1 + 0 * 2 = 9 Time: 8.62 seconds, Memory: 27.46 MB OK (1 test, 1 assertion)
How to use:
Create a class that implements Fgsl\GeneticAlgorithm\RulesInterface
. This class must define fitness function and other constraints.
Inject an instance of rules class in an instance of Fgsl\GeneticAlgorithm\GeneticAlgorithm
and call method execute
.
You can see processing details enabling verbose parameter in class constructor.