|
17 | 17 | from greyjack.agents.base.LoggingLevel import LoggingLevel
|
18 | 18 | from greyjack.agents.termination_strategies import *
|
19 | 19 |
|
20 |
| -from examples.pure_math.minlp.gj_files.rsyn0840m import * |
| 20 | +from examples.pure_math.minlp.gj_files.sssd import * |
21 | 21 |
|
22 | 22 | if __name__ == "__main__":
|
23 | 23 |
|
| 24 | + # for standard LP, QP problems fomulations better use classic solvers (they are specially made for them) |
| 25 | + # one needs metaheuristics, when classic solvers struggle, too difficult or just impossible to use: |
| 26 | + # (difficult functions, fast development, lack of expressiveness (explore OOP API of GreyJack Solver to |
| 27 | + # understand how to express problems by another, much more comfort and easy way), adaptability to new requirements, clarity of |
| 28 | + # processes during optimization, explainability, etc, etc) |
| 29 | + # here I use metaheuristics on standard LP, QP problems by using MathModel API just for benchmarks |
24 | 30 | math_model = build_math_model()
|
25 | 31 |
|
26 | 32 | #termination_strategy = StepsLimit(step_count_limit=1000)
|
27 | 33 | #termination_strategy = TimeSpentLimit(time_seconds_limit=60)
|
28 | 34 | termination_strategy = ScoreNoImprovement(time_seconds_limit=15)
|
29 | 35 | #termination_strategy = ScoreLimit(score_to_compare=[0, 0])
|
| 36 | + |
| 37 | + agent = LSHADE(population_size=128, history_archive_size=100, |
| 38 | + p_best_rate=0.2, tabu_entity_rate=0.2, |
| 39 | + mutation_rate_multiplier=1.0, move_probas=None, |
| 40 | + memory_pruning_rate=0.0, guarantee_of_change_size=0, |
| 41 | + initial_f=0.5, initial_cr=0.02, initial_mutation_proba=0.5, |
| 42 | + migration_rate=0.00001, migration_frequency=100, termination_strategy=termination_strategy) |
| 43 | + """agent = GeneticAlgorithm(population_size=256, crossover_probability=0.8, p_best_rate=0.5, |
| 44 | + tabu_entity_rate=0.8, mutation_rate_multiplier=1.0, move_probas=[0.5, 0.5, 0.0, 0.0, 0.0, 0.0], |
| 45 | + migration_rate=0.00001, migration_frequency=10, termination_strategy=termination_strategy)""" |
30 | 46 | """agent = TabuSearch(neighbours_count=1000, tabu_entity_rate=0.8,
|
31 | 47 | mutation_rate_multiplier=1.0, move_probas=[0.5, 0.5, 0.0, 0.0, 0.0, 0.0],
|
32 | 48 | compare_to_global_frequency=10, termination_strategy=termination_strategy)"""
|
33 |
| - agent = GeneticAlgorithm(population_size=256, crossover_probability=0.8, p_best_rate=0.5, |
34 |
| - tabu_entity_rate=0.8, mutation_rate_multiplier=1.0, move_probas=[0.5, 0.5, 0.0, 0.0, 0.0, 0.0], |
35 |
| - migration_rate=0.00001, migration_frequency=10, termination_strategy=termination_strategy) |
36 | 49 | """agent = LateAcceptance(late_acceptance_size=200, tabu_entity_rate=0.8,
|
37 | 50 | mutation_rate_multiplier=1.0, move_probas=[0.5, 0.5, 0.0, 0.0, 0.0, 0.0],
|
38 | 51 | compare_to_global_frequency=10000, termination_strategy=termination_strategy)"""
|
|
42 | 55 |
|
43 | 56 | solver = SolverPureMath(math_model, agent,
|
44 | 57 | ParallelizationBackend.Multiprocessing, LoggingLevel.FreshOnly,
|
45 |
| - n_jobs=10, score_precision=[6, 2]) |
| 58 | + n_jobs=10, score_precision=[4, 2]) |
46 | 59 | solution = solver.solve()
|
47 | 60 | math_model.explain_solution( solution )
|
48 | 61 |
|
|
0 commit comments