From a069bae234fce22068be8ed9ae0cc061b4c580e7 Mon Sep 17 00:00:00 2001 From: Demetry Pascal Date: Sun, 14 Apr 2024 09:55:00 +0300 Subject: [PATCH] rename tests -> examples --- README.md | 86 +++++++++--------- {tests => examples}/AlgorithmParameters.py | 0 .../Standard GA vs. Elitist GA.py | 0 {tests => examples}/_sense_of_prob_cross.py | 0 {tests => examples}/best_of_N.py | 0 {tests => examples}/best_of_N_with_opp.py | 0 {tests => examples}/best_subset.py | 0 {tests => examples}/callbacks.py | 0 .../check_new_types_of_cross_and_mut.py | 0 {tests => examples}/constraints.py | 0 {tests => examples}/crossovers_examples.py | 0 .../disable_messages_and_printing.py | 0 {tests => examples}/init_local_opt.py | 0 {tests => examples}/min of sum int.py | 24 +++-- {tests => examples}/min of sum mixed.py | 0 {tests => examples}/min of sum.py | 0 {tests => examples}/multiprocess.py | 0 {tests => examples}/mut_indexes.py | 0 .../optimization_test_functions.py | 0 {tests => examples}/output/1212.0.png | Bin {tests => examples}/output/1258.0.png | Bin {tests => examples}/output/1321.0.png | Bin {tests => examples}/output/1350.0.png | Bin {tests => examples}/output/1389.0.png | Bin {tests => examples}/output/1394.0.png | Bin {tests => examples}/output/1507.0.png | Bin {tests => examples}/output/1742.0.png | Bin .../callback/plot_example/plot_1200.png | Bin .../callback/plot_example/plot_1500.png | Bin .../callback/plot_example/plot_1800.png | Bin .../output/callback/plot_example/plot_300.png | Bin .../output/callback/plot_example/plot_600.png | Bin .../output/callback/plot_example/plot_900.png | Bin .../callback/pop_example/constraints_1000.npz | Bin .../callback/pop_example/constraints_1500.npz | Bin .../callback/pop_example/constraints_2000.npz | Bin .../callback/pop_example/constraints_500.npz | Bin .../output/crossovers_example.txt | 0 .../output/eggholder_lastgen.npz | Bin {tests => examples}/output/init_best_of.png | Bin .../output/init_best_of_opp.png | Bin {tests => examples}/output/init_local_opt.png | Bin .../Optimization process for Abs.png | Bin .../Optimization process for Ackley.png | Bin .../Optimization process for AckleyTest.png | Bin .../Optimization process for Eggholder.png | Bin .../Optimization process for Fletcher.png | Bin .../Optimization process for Griewank.png | Bin .../Optimization process for Michalewicz.png | Bin .../Optimization process for Penalty2.png | Bin .../Optimization process for Quartic.png | Bin .../Optimization process for Rastrigin.png | Bin .../Optimization process for Rosenbrock.png | Bin .../Optimization process for Scheffer.png | Bin .../Optimization process for SchwefelAbs.png | Bin ...ptimization process for SchwefelDouble.png | Bin .../Optimization process for SchwefelMax.png | Bin .../Optimization process for SchwefelSin.png | Bin .../Optimization process for Sphere.png | Bin .../Optimization process for Stairs.png | Bin .../Optimization process for Weierstrass.png | Bin .../optimization_test_func_code_for_md.txt | 0 .../output/plot_scores_end.png | Bin .../output/plot_scores_process.png | Bin .../output/plot_scores_start.png | Bin {tests => examples}/output/remove_dups.png | Bin {tests => examples}/output/report.png | Bin {tests => examples}/output/revolution.png | Bin {tests => examples}/output/selections.png | Bin .../sense_of_crossover_prob__no_sense.png | Bin .../output/standard_vs_elitist.png | Bin {tests => examples}/output/studEA.png | Bin {tests => examples}/output/with_dups.png | Bin {tests => examples}/output/without_dups.png | Bin {tests => examples}/plot_diversities.py | 0 {tests => examples}/plot_each_gen_scores.py | 0 {tests => examples}/plot_scores.py | 0 {tests => examples}/progress_bar_streams.py | 0 {tests => examples}/remove_dups.py | 0 .../remove_dups_by_callback.py | 0 {tests => examples}/report.py | 0 {tests => examples}/revolution.py | 0 .../save and load generation.py | 0 {tests => examples}/selections.py | 0 {tests => examples}/set_functions.py | 0 {tests => examples}/small_middle_callbacks.py | 0 {tests => examples}/start_gen.py | 0 {tests => examples}/str.py | 0 {tests => examples}/studEA.py | 0 {tests => examples}/test_all.py | 0 .../test_functions_code_list.py | 0 {tests => examples}/time_limit.py | 0 92 files changed, 54 insertions(+), 56 deletions(-) rename {tests => examples}/AlgorithmParameters.py (100%) rename {tests => examples}/Standard GA vs. Elitist GA.py (100%) rename {tests => examples}/_sense_of_prob_cross.py (100%) rename {tests => examples}/best_of_N.py (100%) rename {tests => examples}/best_of_N_with_opp.py (100%) rename {tests => examples}/best_subset.py (100%) rename {tests => examples}/callbacks.py (100%) rename {tests => examples}/check_new_types_of_cross_and_mut.py (100%) rename {tests => examples}/constraints.py (100%) rename {tests => examples}/crossovers_examples.py (100%) rename {tests => examples}/disable_messages_and_printing.py (100%) rename {tests => examples}/init_local_opt.py (100%) rename {tests => examples}/min of sum int.py (63%) rename {tests => examples}/min of sum mixed.py (100%) rename {tests => examples}/min of sum.py (100%) rename {tests => examples}/multiprocess.py (100%) rename {tests => examples}/mut_indexes.py (100%) rename {tests => examples}/optimization_test_functions.py (100%) rename {tests => examples}/output/1212.0.png (100%) rename {tests => examples}/output/1258.0.png (100%) rename {tests => examples}/output/1321.0.png (100%) rename {tests => examples}/output/1350.0.png (100%) rename {tests => examples}/output/1389.0.png (100%) rename {tests => examples}/output/1394.0.png (100%) rename {tests => examples}/output/1507.0.png (100%) rename {tests => examples}/output/1742.0.png (100%) rename {tests => examples}/output/callback/plot_example/plot_1200.png (100%) rename {tests => examples}/output/callback/plot_example/plot_1500.png (100%) rename {tests => examples}/output/callback/plot_example/plot_1800.png (100%) rename {tests => examples}/output/callback/plot_example/plot_300.png (100%) rename {tests => examples}/output/callback/plot_example/plot_600.png (100%) rename {tests => examples}/output/callback/plot_example/plot_900.png (100%) rename {tests => examples}/output/callback/pop_example/constraints_1000.npz (100%) rename {tests => examples}/output/callback/pop_example/constraints_1500.npz (100%) rename {tests => examples}/output/callback/pop_example/constraints_2000.npz (100%) rename {tests => examples}/output/callback/pop_example/constraints_500.npz (100%) rename {tests => examples}/output/crossovers_example.txt (100%) rename {tests => examples}/output/eggholder_lastgen.npz (100%) rename {tests => examples}/output/init_best_of.png (100%) rename {tests => examples}/output/init_best_of_opp.png (100%) rename {tests => examples}/output/init_local_opt.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Abs.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Ackley.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for AckleyTest.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Eggholder.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Fletcher.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Griewank.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Michalewicz.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Penalty2.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Quartic.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Rastrigin.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Rosenbrock.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Scheffer.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for SchwefelAbs.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for SchwefelDouble.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for SchwefelMax.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for SchwefelSin.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Sphere.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Stairs.png (100%) rename {tests => examples}/output/opt_test_funcs/Optimization process for Weierstrass.png (100%) rename {tests => examples}/output/opt_test_funcs/optimization_test_func_code_for_md.txt (100%) rename {tests => examples}/output/plot_scores_end.png (100%) rename {tests => examples}/output/plot_scores_process.png (100%) rename {tests => examples}/output/plot_scores_start.png (100%) rename {tests => examples}/output/remove_dups.png (100%) rename {tests => examples}/output/report.png (100%) rename {tests => examples}/output/revolution.png (100%) rename {tests => examples}/output/selections.png (100%) rename {tests => examples}/output/sense_of_crossover_prob__no_sense.png (100%) rename {tests => examples}/output/standard_vs_elitist.png (100%) rename {tests => examples}/output/studEA.png (100%) rename {tests => examples}/output/with_dups.png (100%) rename {tests => examples}/output/without_dups.png (100%) rename {tests => examples}/plot_diversities.py (100%) rename {tests => examples}/plot_each_gen_scores.py (100%) rename {tests => examples}/plot_scores.py (100%) rename {tests => examples}/progress_bar_streams.py (100%) rename {tests => examples}/remove_dups.py (100%) rename {tests => examples}/remove_dups_by_callback.py (100%) rename {tests => examples}/report.py (100%) rename {tests => examples}/revolution.py (100%) rename {tests => examples}/save and load generation.py (100%) rename {tests => examples}/selections.py (100%) rename {tests => examples}/set_functions.py (100%) rename {tests => examples}/small_middle_callbacks.py (100%) rename {tests => examples}/start_gen.py (100%) rename {tests => examples}/str.py (100%) rename {tests => examples}/studEA.py (100%) rename {tests => examples}/test_all.py (100%) rename {tests => examples}/test_functions_code_list.py (100%) rename {tests => examples}/time_limit.py (100%) diff --git a/README.md b/README.md index a1412fa..e0a1302 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ pip install geneticalgorithm2[full] ## 6.8.0 minor update -- remove `crossover_probability` model parameter because of it has no sense to exist (and 1.0 value is better than others, take a look at [results](/tests/output/sense_of_crossover_prob__no_sense.png)). This parameter came from `geneticalgorithm` old package and did`t change before. +- remove `crossover_probability` model parameter because of it has no sense to exist (and 1.0 value is better than others, take a look at [results](/examples/output/sense_of_crossover_prob__no_sense.png)). This parameter came from `geneticalgorithm` old package and did`t change before. ## 6.7.7 refactor @@ -288,7 +288,7 @@ pip install geneticalgorithm2[full] * `np.ndarray` with shape `(samples, dim)` for only population or `(samples, dim+1)` for concatenated population and score (scores is the last matrix column) * `tuple(np.ndarray/None, np.ndarray/None)` for variables and scores - here `variables` is 2D numpy array with shape `(samples, dim)`, `scores` is 1D numpy array with scores (function values) for each sample; [here](tests/output/start_gen.py) and [here](#how-to-initialize-start-population-how-to-continue-optimization-with-new-run) u can see examples of using these valid forms + here `variables` is 2D numpy array with shape `(samples, dim)`, `scores` is 1D numpy array with scores (function values) for each sample; [here](examples/output/start_gen.py) and [here](#how-to-initialize-start-population-how-to-continue-optimization-with-new-run) u can see examples of using these valid forms ## 6.3.0 minor update (refactoring) @@ -711,7 +711,7 @@ If this parameter's value is `None` the algorithm sets maximum number of iterati # some code return array_of_parents_indexes ``` -![](tests/output/selections.png) +![](examples/output/selections.png) ## Methods and Properties of model: @@ -735,7 +735,7 @@ The main method if **run()**. It has parameters: * tuple of `np.ndarray`s / `None`. * **studEA** (`bool`) - using stud EA strategy (crossover with best object always). Default is false. [Take a look](#standard-crossover-vs-stud-ea-crossover) -* **mutation_indexes** (`Optional[Union[Sequence[int], Set[int]]]`) - indexes of dimensions where mutation can be performed (all dimensions by default). [Example](tests/mut_indexes.py) +* **mutation_indexes** (`Optional[Union[Sequence[int], Set[int]]]`) - indexes of dimensions where mutation can be performed (all dimensions by default). [Example](examples/mut_indexes.py) * **init_creator**: (`Optional[Callable[[], np.ndarray]]`), the function creates population samples. By default -- random uniform for real variables and random uniform for int. [Example](#optimization-with-oppositions) * **init_oppositors**: (`Optional[Sequence[Callable[[np.ndarray], np.ndarray]]]`) -- the list of oppositors creates oppositions for base population. No by default. [Example](#optimization-with-oppositions) @@ -756,14 +756,14 @@ The main method if **run()**. It has parameters: # do some action # ``` - See [example of using callbacks](tests/callbacks.py). There are several callbacks in `Callbacks` class, such as: + See [example of using callbacks](examples/callbacks.py). There are several callbacks in `Callbacks` class, such as: * `Callbacks.SavePopulation(folder, save_gen_step = 50, file_prefix = 'population')` * `Callbacks.PlotOptimizationProcess(folder, save_gen_step = 50, show = False, main_color = 'green', file_prefix = 'report')` * **middle_callbacks** (`Sequence`) - list of functions made `MiddleCallbacks` class (large opportunity, please, have a look at [this](#middle-callbacks)) -* **time_limit_secs** (`Optional[float]`) - limit time of working (in seconds). If `None`, there is no time limit (limit only for count of generation and so on). See [little example of using](tests/time_limit.py). Also there is simple conversion function for conversion some time in seconds: +* **time_limit_secs** (`Optional[float]`) - limit time of working (in seconds). If `None`, there is no time limit (limit only for count of generation and so on). See [little example of using](examples/time_limit.py). Also there is simple conversion function for conversion some time in seconds: ```python from truefalsepython import time_to_seconds @@ -1020,7 +1020,7 @@ model.run(no_plot=False, start_generation=(start_generation, None)) ## Available crossovers -For two example parents (*one with ones* and *one with zeros*) next crossovers will give same children ([examples](tests/crossovers_examples.py)): +For two example parents (*one with ones* and *one with zeros*) next crossovers will give same children ([examples](examples/crossovers_examples.py)): * **one_point**: @@ -1085,13 +1085,13 @@ make sure to increase function_timeout in arguments. The convergence curve of an elitist genetic algorithm is always non-increasing. So, the best ever found solution is equal to the best solution of the last iteration. However, the convergence curve of a standard genetic algorithm is different. If `elit_ratio` is zero geneticalgorithm2 implements a standard GA. The output of geneticalgorithm2 for standard GA is the best ever found solution not the solution of the last iteration. The difference between the convergence curve of standard GA and elitist GA is shown below: -![](tests/output/standard_vs_elitist.png) +![](examples/output/standard_vs_elitist.png) ## Standard crossover vs. stud EA crossover [Stud EA](https://link.springer.com/chapter/10.1007%2FBFb0056910) is the idea of using crossover always with best object. So one of two parents is always the best object of population. It can help us in a lot of tasks! -![](tests/output/studEA.png) +![](examples/output/studEA.png) ## Creating better start population @@ -1116,7 +1116,7 @@ There is `Population_initializer(select_best_of = 4, local_optimization_step = ' This little option can help u especially with multimodal tasks. -![](tests/output/init_best_of.png) +![](examples/output/init_best_of.png) ### Do local optimization @@ -1173,26 +1173,26 @@ plt.title('Selection best N object before running GA') plt.legend() ``` -![](tests/output/init_local_opt.png) +![](examples/output/init_local_opt.png) ### Optimization with oppositions -Also u can create start population with [oppositions](https://github.com/PasaOpasen/opp-op-pop-init). See [example of code](tests/best_of_N_with_opp.py) +Also u can create start population with [oppositions](https://github.com/PasaOpasen/opp-op-pop-init). See [example of code](examples/best_of_N_with_opp.py) -![](tests/output/init_best_of_opp.png) +![](examples/output/init_best_of_opp.png) ## Revolutions -U can create [revolutions in your population](https://github.com/PasaOpasen/opp-op-pop-init) after some stagnation steps. It really can help u for some tasks. See [example](tests/revolution.py) +U can create [revolutions in your population](https://github.com/PasaOpasen/opp-op-pop-init) after some stagnation steps. It really can help u for some tasks. See [example](examples/revolution.py) -![](tests/output/revolution.png) +![](examples/output/revolution.png) ## Duplicates removing -If u remove duplicates each `k` generations, u can speed up the optimization process ([example](tests/remove_dups.py)) +If u remove duplicates each `k` generations, u can speed up the optimization process ([example](examples/remove_dups.py)) -![](tests/output/remove_dups.png) +![](examples/output/remove_dups.png) ## Cache @@ -1270,7 +1270,7 @@ plot_several_lines( ) ``` -![](tests/output/report.png) +![](examples/output/report.png) As u see, u should append tuple `(name of report, func to evaluate report)` to `model.checked_report`. It's highly recommended to start this name with `report_` (e. g. `report_my_median`). And the function u use will get 1D-numpy *sorted* array of population scores. @@ -1329,11 +1329,11 @@ To combine `action` and `condition` to callback, just use `MiddleCallbacks.Unive There are also next high-level useful callbacks: * `MiddleCallbacks.ReduceMutationGen(reduce_coef = 0.9, min_mutation = 0.005, reduce_each_generation = 50, reload_each_generation = 500)` -* `MiddleCallbacks.GeneDiversityStats(step_generations_for_plotting:int = 10)` -- plots some duplicates statistics each gen ([example](/tests/plot_diversities.py)) +* `MiddleCallbacks.GeneDiversityStats(step_generations_for_plotting:int = 10)` -- plots some duplicates statistics each gen ([example](/examples/plot_diversities.py)) ![](diversity.gif) -See [code example](tests/small_middle_callbacks.py) +See [code example](examples/small_middle_callbacks.py) ## How to compare efficiency of several versions of GA optimization @@ -1547,83 +1547,83 @@ model.run(...) Here there is the implementation of `geneticalgorithm2` for some benchmark problems. Test functions are got from my [`OptimizationTestFunctions`](https://github.com/PasaOpasen/OptimizationTestFunctions) package. -The code for optimizations process is same for each function and is contained [in file](tests/optimization_test_functions.py). +The code for optimizations process is same for each function and is contained [in file](examples/optimization_test_functions.py). ### [Sphere](https://github.com/PasaOpasen/OptimizationTestFunctions#sphere) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Sphere.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Sphere.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Sphere.png) ### [Ackley](https://github.com/PasaOpasen/OptimizationTestFunctions#ackley) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Ackley.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Ackley.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Ackley.png) ### [AckleyTest](https://github.com/PasaOpasen/OptimizationTestFunctions#ackleytest) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20AckleyTest.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20AckleyTest.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20AckleyTest.png) ### [Rosenbrock](https://github.com/PasaOpasen/OptimizationTestFunctions#rosenbrock) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Rosenbrock.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Rosenbrock.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Rosenbrock.png) ### [Fletcher](https://github.com/PasaOpasen/OptimizationTestFunctions#fletcher) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Fletcher.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Fletcher.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Fletcher.png) ### [Griewank](https://github.com/PasaOpasen/OptimizationTestFunctions#griewank) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Griewank.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Griewank.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Griewank.png) ### [Penalty2](https://github.com/PasaOpasen/OptimizationTestFunctions#penalty2) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Penalty2.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Penalty2.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Penalty2.png) ### [Quartic](https://github.com/PasaOpasen/OptimizationTestFunctions#quartic) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Quartic.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Quartic.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Quartic.png) ### [Rastrigin](https://github.com/PasaOpasen/OptimizationTestFunctions#rastrigin) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Rastrigin.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Rastrigin.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Rastrigin.png) ### [SchwefelDouble](https://github.com/PasaOpasen/OptimizationTestFunctions#schwefeldouble) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20SchwefelDouble.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20SchwefelDouble.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20SchwefelDouble.png) ### [SchwefelMax](https://github.com/PasaOpasen/OptimizationTestFunctions#schwefelmax) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20SchwefelMax.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20SchwefelMax.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20SchwefelMax.png) ### [SchwefelAbs](https://github.com/PasaOpasen/OptimizationTestFunctions#schwefelabs) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20SchwefelAbs.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20SchwefelAbs.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20SchwefelAbs.png) ### [SchwefelSin](https://github.com/PasaOpasen/OptimizationTestFunctions#schwefelsin) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20SchwefelSin.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20SchwefelSin.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20SchwefelSin.png) ### [Stairs](https://github.com/PasaOpasen/OptimizationTestFunctions#stairs) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Stairs.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Stairs.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Stairs.png) ### [Abs](https://github.com/PasaOpasen/OptimizationTestFunctions#abs) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Abs.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Abs.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Abs.png) ### [Michalewicz](https://github.com/PasaOpasen/OptimizationTestFunctions#michalewicz) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Michalewicz.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Michalewicz.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Michalewicz.png) ### [Scheffer](https://github.com/PasaOpasen/OptimizationTestFunctions#scheffer) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Scheffer.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Scheffer.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Scheffer.png) ### [Eggholder](https://github.com/PasaOpasen/OptimizationTestFunctions#eggholder) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Eggholder.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Eggholder.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Eggholder.png) ### [Weierstrass](https://github.com/PasaOpasen/OptimizationTestFunctions#weierstrass) ![](https://github.com/PasaOpasen/OptimizationTestFunctions/blob/main/tests/heatmap%20for%20Weierstrass.png) -![](tests/output/opt_test_funcs/Optimization%20process%20for%20Weierstrass.png) +![](examples/output/opt_test_funcs/Optimization%20process%20for%20Weierstrass.png) @@ -1713,9 +1713,9 @@ model.plot_results(save_as='plot_scores_process.png') # plot scores of last population model.plot_generation_scores(title='Population scores after ending of searching', save_as='plot_scores_end.png') ``` -![](tests/output/plot_scores_start.png) -![](tests/output/plot_scores_process.png) -![](tests/output/plot_scores_end.png) +![](examples/output/plot_scores_start.png) +![](examples/output/plot_scores_process.png) +![](examples/output/plot_scores_end.png) diff --git a/tests/AlgorithmParameters.py b/examples/AlgorithmParameters.py similarity index 100% rename from tests/AlgorithmParameters.py rename to examples/AlgorithmParameters.py diff --git a/tests/Standard GA vs. Elitist GA.py b/examples/Standard GA vs. Elitist GA.py similarity index 100% rename from tests/Standard GA vs. Elitist GA.py rename to examples/Standard GA vs. Elitist GA.py diff --git a/tests/_sense_of_prob_cross.py b/examples/_sense_of_prob_cross.py similarity index 100% rename from tests/_sense_of_prob_cross.py rename to examples/_sense_of_prob_cross.py diff --git a/tests/best_of_N.py b/examples/best_of_N.py similarity index 100% rename from tests/best_of_N.py rename to examples/best_of_N.py diff --git a/tests/best_of_N_with_opp.py b/examples/best_of_N_with_opp.py similarity index 100% rename from tests/best_of_N_with_opp.py rename to examples/best_of_N_with_opp.py diff --git a/tests/best_subset.py b/examples/best_subset.py similarity index 100% rename from tests/best_subset.py rename to examples/best_subset.py diff --git a/tests/callbacks.py b/examples/callbacks.py similarity index 100% rename from tests/callbacks.py rename to examples/callbacks.py diff --git a/tests/check_new_types_of_cross_and_mut.py b/examples/check_new_types_of_cross_and_mut.py similarity index 100% rename from tests/check_new_types_of_cross_and_mut.py rename to examples/check_new_types_of_cross_and_mut.py diff --git a/tests/constraints.py b/examples/constraints.py similarity index 100% rename from tests/constraints.py rename to examples/constraints.py diff --git a/tests/crossovers_examples.py b/examples/crossovers_examples.py similarity index 100% rename from tests/crossovers_examples.py rename to examples/crossovers_examples.py diff --git a/tests/disable_messages_and_printing.py b/examples/disable_messages_and_printing.py similarity index 100% rename from tests/disable_messages_and_printing.py rename to examples/disable_messages_and_printing.py diff --git a/tests/init_local_opt.py b/examples/init_local_opt.py similarity index 100% rename from tests/init_local_opt.py rename to examples/init_local_opt.py diff --git a/tests/min of sum int.py b/examples/min of sum int.py similarity index 63% rename from tests/min of sum int.py rename to examples/min of sum int.py index 62cf68d..0cb853b 100644 --- a/tests/min of sum int.py +++ b/examples/min of sum int.py @@ -6,21 +6,22 @@ """ import sys + sys.path.append('..') import numpy as np from geneticalgorithm2 import GeneticAlgorithm2 as ga + def f(X): return np.sum(X) - - -varbound = [[0,10]]*3 -model = ga(function=f, dimension=3, variable_type='int', variable_boundaries=varbound) -model.run() +varbound = [[0, 10]] * 3 + +model = ga(dimension=3, variable_type='int', variable_boundaries=varbound) +model.run(function=f, ) # check discrete mutation @@ -30,21 +31,18 @@ def f(X): dimension=300, variable_type='int', variable_boundaries=varbound, algorithm_parameters={ - 'mutation_discrete_type': 'uniform_discrete', - 'max_num_iteration': 1000 + 'mutation_discrete_type': 'uniform_discrete', + 'max_num_iteration': 1000 } ) -model.run(stop_when_reached=0, function=f,) +model.run(stop_when_reached=0, function=f, ) - -model = ga(function=f, dimension=300, variable_type='int', +model = ga(dimension=300, variable_type='int', variable_boundaries=varbound, algorithm_parameters={ 'mutation_discrete_type': lambda x, left, right: left, 'max_num_iteration': 1000 }) -model.run(stop_when_reached=0) - - +model.run(function=f, stop_when_reached=0) diff --git a/tests/min of sum mixed.py b/examples/min of sum mixed.py similarity index 100% rename from tests/min of sum mixed.py rename to examples/min of sum mixed.py diff --git a/tests/min of sum.py b/examples/min of sum.py similarity index 100% rename from tests/min of sum.py rename to examples/min of sum.py diff --git a/tests/multiprocess.py b/examples/multiprocess.py similarity index 100% rename from tests/multiprocess.py rename to examples/multiprocess.py diff --git a/tests/mut_indexes.py b/examples/mut_indexes.py similarity index 100% rename from tests/mut_indexes.py rename to examples/mut_indexes.py diff --git a/tests/optimization_test_functions.py b/examples/optimization_test_functions.py similarity index 100% rename from tests/optimization_test_functions.py rename to examples/optimization_test_functions.py diff --git a/tests/output/1212.0.png b/examples/output/1212.0.png similarity index 100% rename from tests/output/1212.0.png rename to examples/output/1212.0.png diff --git a/tests/output/1258.0.png b/examples/output/1258.0.png similarity index 100% rename from tests/output/1258.0.png rename to examples/output/1258.0.png diff --git a/tests/output/1321.0.png b/examples/output/1321.0.png similarity index 100% rename from tests/output/1321.0.png rename to examples/output/1321.0.png diff --git a/tests/output/1350.0.png b/examples/output/1350.0.png similarity index 100% rename from tests/output/1350.0.png rename to examples/output/1350.0.png diff --git a/tests/output/1389.0.png b/examples/output/1389.0.png similarity index 100% rename from tests/output/1389.0.png rename to examples/output/1389.0.png diff --git a/tests/output/1394.0.png b/examples/output/1394.0.png similarity index 100% rename from tests/output/1394.0.png rename to examples/output/1394.0.png diff --git a/tests/output/1507.0.png b/examples/output/1507.0.png similarity index 100% rename from tests/output/1507.0.png rename to examples/output/1507.0.png diff --git a/tests/output/1742.0.png b/examples/output/1742.0.png similarity index 100% rename from tests/output/1742.0.png rename to examples/output/1742.0.png diff --git a/tests/output/callback/plot_example/plot_1200.png b/examples/output/callback/plot_example/plot_1200.png similarity index 100% rename from tests/output/callback/plot_example/plot_1200.png rename to examples/output/callback/plot_example/plot_1200.png diff --git a/tests/output/callback/plot_example/plot_1500.png b/examples/output/callback/plot_example/plot_1500.png similarity index 100% rename from tests/output/callback/plot_example/plot_1500.png rename to examples/output/callback/plot_example/plot_1500.png diff --git a/tests/output/callback/plot_example/plot_1800.png b/examples/output/callback/plot_example/plot_1800.png similarity index 100% rename from tests/output/callback/plot_example/plot_1800.png rename to examples/output/callback/plot_example/plot_1800.png diff --git a/tests/output/callback/plot_example/plot_300.png b/examples/output/callback/plot_example/plot_300.png similarity index 100% rename from tests/output/callback/plot_example/plot_300.png rename to examples/output/callback/plot_example/plot_300.png diff --git a/tests/output/callback/plot_example/plot_600.png b/examples/output/callback/plot_example/plot_600.png similarity index 100% rename from tests/output/callback/plot_example/plot_600.png rename to examples/output/callback/plot_example/plot_600.png diff --git a/tests/output/callback/plot_example/plot_900.png b/examples/output/callback/plot_example/plot_900.png similarity index 100% rename from tests/output/callback/plot_example/plot_900.png rename to examples/output/callback/plot_example/plot_900.png diff --git a/tests/output/callback/pop_example/constraints_1000.npz b/examples/output/callback/pop_example/constraints_1000.npz similarity index 100% rename from tests/output/callback/pop_example/constraints_1000.npz rename to examples/output/callback/pop_example/constraints_1000.npz diff --git a/tests/output/callback/pop_example/constraints_1500.npz b/examples/output/callback/pop_example/constraints_1500.npz similarity index 100% rename from tests/output/callback/pop_example/constraints_1500.npz rename to examples/output/callback/pop_example/constraints_1500.npz diff --git a/tests/output/callback/pop_example/constraints_2000.npz b/examples/output/callback/pop_example/constraints_2000.npz similarity index 100% rename from tests/output/callback/pop_example/constraints_2000.npz rename to examples/output/callback/pop_example/constraints_2000.npz diff --git a/tests/output/callback/pop_example/constraints_500.npz b/examples/output/callback/pop_example/constraints_500.npz similarity index 100% rename from tests/output/callback/pop_example/constraints_500.npz rename to examples/output/callback/pop_example/constraints_500.npz diff --git a/tests/output/crossovers_example.txt b/examples/output/crossovers_example.txt similarity index 100% rename from tests/output/crossovers_example.txt rename to examples/output/crossovers_example.txt diff --git a/tests/output/eggholder_lastgen.npz b/examples/output/eggholder_lastgen.npz similarity index 100% rename from tests/output/eggholder_lastgen.npz rename to examples/output/eggholder_lastgen.npz diff --git a/tests/output/init_best_of.png b/examples/output/init_best_of.png similarity index 100% rename from tests/output/init_best_of.png rename to examples/output/init_best_of.png diff --git a/tests/output/init_best_of_opp.png b/examples/output/init_best_of_opp.png similarity index 100% rename from tests/output/init_best_of_opp.png rename to examples/output/init_best_of_opp.png diff --git a/tests/output/init_local_opt.png b/examples/output/init_local_opt.png similarity index 100% rename from tests/output/init_local_opt.png rename to examples/output/init_local_opt.png diff --git a/tests/output/opt_test_funcs/Optimization process for Abs.png b/examples/output/opt_test_funcs/Optimization process for Abs.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Abs.png rename to examples/output/opt_test_funcs/Optimization process for Abs.png diff --git a/tests/output/opt_test_funcs/Optimization process for Ackley.png b/examples/output/opt_test_funcs/Optimization process for Ackley.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Ackley.png rename to examples/output/opt_test_funcs/Optimization process for Ackley.png diff --git a/tests/output/opt_test_funcs/Optimization process for AckleyTest.png b/examples/output/opt_test_funcs/Optimization process for AckleyTest.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for AckleyTest.png rename to examples/output/opt_test_funcs/Optimization process for AckleyTest.png diff --git a/tests/output/opt_test_funcs/Optimization process for Eggholder.png b/examples/output/opt_test_funcs/Optimization process for Eggholder.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Eggholder.png rename to examples/output/opt_test_funcs/Optimization process for Eggholder.png diff --git a/tests/output/opt_test_funcs/Optimization process for Fletcher.png b/examples/output/opt_test_funcs/Optimization process for Fletcher.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Fletcher.png rename to examples/output/opt_test_funcs/Optimization process for Fletcher.png diff --git a/tests/output/opt_test_funcs/Optimization process for Griewank.png b/examples/output/opt_test_funcs/Optimization process for Griewank.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Griewank.png rename to examples/output/opt_test_funcs/Optimization process for Griewank.png diff --git a/tests/output/opt_test_funcs/Optimization process for Michalewicz.png b/examples/output/opt_test_funcs/Optimization process for Michalewicz.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Michalewicz.png rename to examples/output/opt_test_funcs/Optimization process for Michalewicz.png diff --git a/tests/output/opt_test_funcs/Optimization process for Penalty2.png b/examples/output/opt_test_funcs/Optimization process for Penalty2.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Penalty2.png rename to examples/output/opt_test_funcs/Optimization process for Penalty2.png diff --git a/tests/output/opt_test_funcs/Optimization process for Quartic.png b/examples/output/opt_test_funcs/Optimization process for Quartic.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Quartic.png rename to examples/output/opt_test_funcs/Optimization process for Quartic.png diff --git a/tests/output/opt_test_funcs/Optimization process for Rastrigin.png b/examples/output/opt_test_funcs/Optimization process for Rastrigin.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Rastrigin.png rename to examples/output/opt_test_funcs/Optimization process for Rastrigin.png diff --git a/tests/output/opt_test_funcs/Optimization process for Rosenbrock.png b/examples/output/opt_test_funcs/Optimization process for Rosenbrock.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Rosenbrock.png rename to examples/output/opt_test_funcs/Optimization process for Rosenbrock.png diff --git a/tests/output/opt_test_funcs/Optimization process for Scheffer.png b/examples/output/opt_test_funcs/Optimization process for Scheffer.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Scheffer.png rename to examples/output/opt_test_funcs/Optimization process for Scheffer.png diff --git a/tests/output/opt_test_funcs/Optimization process for SchwefelAbs.png b/examples/output/opt_test_funcs/Optimization process for SchwefelAbs.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for SchwefelAbs.png rename to examples/output/opt_test_funcs/Optimization process for SchwefelAbs.png diff --git a/tests/output/opt_test_funcs/Optimization process for SchwefelDouble.png b/examples/output/opt_test_funcs/Optimization process for SchwefelDouble.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for SchwefelDouble.png rename to examples/output/opt_test_funcs/Optimization process for SchwefelDouble.png diff --git a/tests/output/opt_test_funcs/Optimization process for SchwefelMax.png b/examples/output/opt_test_funcs/Optimization process for SchwefelMax.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for SchwefelMax.png rename to examples/output/opt_test_funcs/Optimization process for SchwefelMax.png diff --git a/tests/output/opt_test_funcs/Optimization process for SchwefelSin.png b/examples/output/opt_test_funcs/Optimization process for SchwefelSin.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for SchwefelSin.png rename to examples/output/opt_test_funcs/Optimization process for SchwefelSin.png diff --git a/tests/output/opt_test_funcs/Optimization process for Sphere.png b/examples/output/opt_test_funcs/Optimization process for Sphere.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Sphere.png rename to examples/output/opt_test_funcs/Optimization process for Sphere.png diff --git a/tests/output/opt_test_funcs/Optimization process for Stairs.png b/examples/output/opt_test_funcs/Optimization process for Stairs.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Stairs.png rename to examples/output/opt_test_funcs/Optimization process for Stairs.png diff --git a/tests/output/opt_test_funcs/Optimization process for Weierstrass.png b/examples/output/opt_test_funcs/Optimization process for Weierstrass.png similarity index 100% rename from tests/output/opt_test_funcs/Optimization process for Weierstrass.png rename to examples/output/opt_test_funcs/Optimization process for Weierstrass.png diff --git a/tests/output/opt_test_funcs/optimization_test_func_code_for_md.txt b/examples/output/opt_test_funcs/optimization_test_func_code_for_md.txt similarity index 100% rename from tests/output/opt_test_funcs/optimization_test_func_code_for_md.txt rename to examples/output/opt_test_funcs/optimization_test_func_code_for_md.txt diff --git a/tests/output/plot_scores_end.png b/examples/output/plot_scores_end.png similarity index 100% rename from tests/output/plot_scores_end.png rename to examples/output/plot_scores_end.png diff --git a/tests/output/plot_scores_process.png b/examples/output/plot_scores_process.png similarity index 100% rename from tests/output/plot_scores_process.png rename to examples/output/plot_scores_process.png diff --git a/tests/output/plot_scores_start.png b/examples/output/plot_scores_start.png similarity index 100% rename from tests/output/plot_scores_start.png rename to examples/output/plot_scores_start.png diff --git a/tests/output/remove_dups.png b/examples/output/remove_dups.png similarity index 100% rename from tests/output/remove_dups.png rename to examples/output/remove_dups.png diff --git a/tests/output/report.png b/examples/output/report.png similarity index 100% rename from tests/output/report.png rename to examples/output/report.png diff --git a/tests/output/revolution.png b/examples/output/revolution.png similarity index 100% rename from tests/output/revolution.png rename to examples/output/revolution.png diff --git a/tests/output/selections.png b/examples/output/selections.png similarity index 100% rename from tests/output/selections.png rename to examples/output/selections.png diff --git a/tests/output/sense_of_crossover_prob__no_sense.png b/examples/output/sense_of_crossover_prob__no_sense.png similarity index 100% rename from tests/output/sense_of_crossover_prob__no_sense.png rename to examples/output/sense_of_crossover_prob__no_sense.png diff --git a/tests/output/standard_vs_elitist.png b/examples/output/standard_vs_elitist.png similarity index 100% rename from tests/output/standard_vs_elitist.png rename to examples/output/standard_vs_elitist.png diff --git a/tests/output/studEA.png b/examples/output/studEA.png similarity index 100% rename from tests/output/studEA.png rename to examples/output/studEA.png diff --git a/tests/output/with_dups.png b/examples/output/with_dups.png similarity index 100% rename from tests/output/with_dups.png rename to examples/output/with_dups.png diff --git a/tests/output/without_dups.png b/examples/output/without_dups.png similarity index 100% rename from tests/output/without_dups.png rename to examples/output/without_dups.png diff --git a/tests/plot_diversities.py b/examples/plot_diversities.py similarity index 100% rename from tests/plot_diversities.py rename to examples/plot_diversities.py diff --git a/tests/plot_each_gen_scores.py b/examples/plot_each_gen_scores.py similarity index 100% rename from tests/plot_each_gen_scores.py rename to examples/plot_each_gen_scores.py diff --git a/tests/plot_scores.py b/examples/plot_scores.py similarity index 100% rename from tests/plot_scores.py rename to examples/plot_scores.py diff --git a/tests/progress_bar_streams.py b/examples/progress_bar_streams.py similarity index 100% rename from tests/progress_bar_streams.py rename to examples/progress_bar_streams.py diff --git a/tests/remove_dups.py b/examples/remove_dups.py similarity index 100% rename from tests/remove_dups.py rename to examples/remove_dups.py diff --git a/tests/remove_dups_by_callback.py b/examples/remove_dups_by_callback.py similarity index 100% rename from tests/remove_dups_by_callback.py rename to examples/remove_dups_by_callback.py diff --git a/tests/report.py b/examples/report.py similarity index 100% rename from tests/report.py rename to examples/report.py diff --git a/tests/revolution.py b/examples/revolution.py similarity index 100% rename from tests/revolution.py rename to examples/revolution.py diff --git a/tests/save and load generation.py b/examples/save and load generation.py similarity index 100% rename from tests/save and load generation.py rename to examples/save and load generation.py diff --git a/tests/selections.py b/examples/selections.py similarity index 100% rename from tests/selections.py rename to examples/selections.py diff --git a/tests/set_functions.py b/examples/set_functions.py similarity index 100% rename from tests/set_functions.py rename to examples/set_functions.py diff --git a/tests/small_middle_callbacks.py b/examples/small_middle_callbacks.py similarity index 100% rename from tests/small_middle_callbacks.py rename to examples/small_middle_callbacks.py diff --git a/tests/start_gen.py b/examples/start_gen.py similarity index 100% rename from tests/start_gen.py rename to examples/start_gen.py diff --git a/tests/str.py b/examples/str.py similarity index 100% rename from tests/str.py rename to examples/str.py diff --git a/tests/studEA.py b/examples/studEA.py similarity index 100% rename from tests/studEA.py rename to examples/studEA.py diff --git a/tests/test_all.py b/examples/test_all.py similarity index 100% rename from tests/test_all.py rename to examples/test_all.py diff --git a/tests/test_functions_code_list.py b/examples/test_functions_code_list.py similarity index 100% rename from tests/test_functions_code_list.py rename to examples/test_functions_code_list.py diff --git a/tests/time_limit.py b/examples/time_limit.py similarity index 100% rename from tests/time_limit.py rename to examples/time_limit.py