From 2713e79215792ce31b8413928f0cf50bf4f103bf Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Tue, 12 Mar 2024 13:46:10 +0200 Subject: [PATCH 1/6] add total iterations --- module/move/optimization_tools/Cargo.toml | 2 +- .../src/optimal_params_search/mod.rs | 2 +- .../src/optimal_params_search/nelder_mead.rs | 42 ++-- .../move/optimization_tools/sudoku_results.md | 94 +++++---- .../optimization_tools/tests/opt_params.rs | 186 ++++++------------ module/move/optimization_tools/tsp_results.md | 80 ++++---- 6 files changed, 193 insertions(+), 213 deletions(-) diff --git a/module/move/optimization_tools/Cargo.toml b/module/move/optimization_tools/Cargo.toml index 79f8029589..745b09706a 100644 --- a/module/move/optimization_tools/Cargo.toml +++ b/module/move/optimization_tools/Cargo.toml @@ -37,7 +37,7 @@ dynamic_plot = [ "static_plot", "plotters-backend", "piston_window" ] lp_parse = [ "exmex" ] [dependencies] -derive_tools = { workspace = true, features = [ "derive_more", "full" ] } +derive_tools = { workspace = true, features = [ "derive_more", "full", "strum" ] } deterministic_rand = { workspace = true, features = [ "default" ] } iter_tools = { workspace = true, features = [ "default" ] } meta_tools = { workspace = true, features = [ "meta_constructors" ] } diff --git a/module/move/optimization_tools/src/optimal_params_search/mod.rs b/module/move/optimization_tools/src/optimal_params_search/mod.rs index 76b84b8492..39390502e0 100644 --- a/module/move/optimization_tools/src/optimal_params_search/mod.rs +++ b/module/move/optimization_tools/src/optimal_params_search/mod.rs @@ -31,7 +31,7 @@ impl Default for OptimalParamsConfig { improvement_threshold : 0.005, max_no_improvement_steps : 10, - max_iterations : 100, + max_iterations : 50, } } } diff --git a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs index 90c329dba4..a82ebb4926 100644 --- a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs +++ b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs @@ -4,10 +4,7 @@ use std:: { - collections::HashMap, - fs::{ File, OpenOptions }, - ops::{ Bound, RangeBounds }, - sync::{ Arc, Mutex }, + collections::HashMap, fs::{ File, OpenOptions }, ops::{ Bound, RangeBounds }, sync::{ Arc, Mutex } }; use deterministic_rand::{ Hrng, Seed, Rng }; use iter_tools::Itertools; @@ -65,7 +62,9 @@ impl Constraints #[ derive( Debug, Clone ) ] pub struct Stats { - + pub number_of_iterations : usize, + pub number_of_starting_points : usize, + pub resumed_after_stale : usize, pub starting_point : Point, pub differences : Vec< Vec< f64 > >, pub positive_change : Vec< usize >, @@ -79,6 +78,9 @@ impl Stats let dimensions = starting_point.coords.len(); Self { + number_of_iterations : 0, + number_of_starting_points : 1, + resumed_after_stale : 0, starting_point, differences : vec![ Vec::new(); dimensions ], positive_change : vec![ 0; dimensions ], @@ -488,6 +490,7 @@ where R : RangeBounds< f64 > + Sync, let results = points.into_par_iter().map( | point | { let mut stats = Stats::new( point.clone() ); + stats.number_of_starting_points = points_number; let x0 = point.clone(); let dimensions = x0.coords.len(); let mut prev_best = self.evaluate_point( &x0, &mut stats ); @@ -509,6 +512,7 @@ where R : RangeBounds< f64 > + Sync, if self.max_iterations <= iterations { + stats.number_of_iterations = iterations; return Result::< Solution, Error >::Ok ( Solution { point : res[ 0 ].0.clone(), @@ -518,10 +522,12 @@ where R : RangeBounds< f64 > + Sync, } ) } - iterations += 1; - if best.1 < prev_best - self.improvement_threshold { + if steps_with_no_improv > 0 + { + stats.resumed_after_stale += 1; + } steps_with_no_improv = 0; prev_best = best.1; } @@ -532,6 +538,7 @@ where R : RangeBounds< f64 > + Sync, if steps_with_no_improv >= self.max_no_improvement_steps { + stats.number_of_iterations = iterations; return Ok ( Solution { point : res[ 0 ].0.clone(), @@ -540,6 +547,8 @@ where R : RangeBounds< f64 > + Sync, stats : Some( stats ), } ) } + + iterations += 1; //centroid let mut x0_center = vec![ 0.0; dimensions ]; @@ -569,7 +578,6 @@ where R : RangeBounds< f64 > + Sync, let prev_point = res.pop().unwrap().0; stats.record_positive_change( &prev_point, &x_ref ); res.push( ( x_ref, reflection_score ) ); - // log::info!("reflection"); continue; } @@ -591,7 +599,6 @@ where R : RangeBounds< f64 > + Sync, let prev_point = res.pop().unwrap().0; stats.record_positive_change( &prev_point, &x_exp ); res.push( ( x_exp, expansion_score ) ); - // log::info!("expansion"); continue; } @@ -600,7 +607,6 @@ where R : RangeBounds< f64 > + Sync, let prev_point = res.pop().unwrap().0; stats.record_positive_change( &prev_point, &x_ref ); res.push( ( x_ref, reflection_score ) ); - // log::info!("expansion"); continue; } } @@ -620,7 +626,6 @@ where R : RangeBounds< f64 > + Sync, let prev_point = res.pop().unwrap().0; stats.record_positive_change( &prev_point, &x_con ); res.push( ( x_con, contraction_score ) ); - // log::info!("contraction"); continue; } @@ -639,7 +644,6 @@ where R : RangeBounds< f64 > + Sync, let score = self.evaluate_point( &x_shrink, &mut stats ); new_res.push( ( x_shrink, score ) ); } - // log::info!("shrink"); res = new_res; } } ).collect::< Vec<_> >(); @@ -828,7 +832,7 @@ pub struct Solution } /// Reasons for termination of optimization process. -#[ derive( Debug, Clone ) ] +#[ derive( Debug, Clone, derive_tools::Display ) ] pub enum TerminationReason { /// Reached limit of total iterations. @@ -837,6 +841,18 @@ pub enum TerminationReason NoImprovement, } +// impl std::fmt::Display for TerminationReason +// { +// fn fmt( &self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result +// { +// match self +// { +// Self::MaxIterations => write!( f, "Exceeded max number of total iterations" ), +// Self::NoImprovement => write!( f, "Exceeded max number of iterations without improvement" ), +// } +// } +// } + /// Possible error when building NMOptimizer. #[ derive( thiserror::Error, Debug ) ] pub enum Error { diff --git a/module/move/optimization_tools/sudoku_results.md b/module/move/optimization_tools/sudoku_results.md index e346a06069..d6b9c2b786 100644 --- a/module/move/optimization_tools/sudoku_results.md +++ b/module/move/optimization_tools/sudoku_results.md @@ -2,19 +2,23 @@ ## For hybrid: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 19 from 48 + - termination reason: NoImprovement - - points from cache: 29 from 48 + - iterations number: 48 + + - resumed after stale: 8 + + - points from cache: 43/133 - level: Easy - - execution time: 0.154s + - execution time: 0.117s - parameters: @@ -22,32 +26,32 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.8561 │ 0.00 │ 1.00 │ 0.02 │ 0.00 │ 9 │ 0.9995 │ +│ temperature │ 0.4043 │ 0.00 │ 1.00 │ 0.10 │ 0.00 │ 41 │ 1.0000 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 106 │ 10.00 │ 200.00 │ 311.97 │ 7.43 │ 9 │ 108 │ +│ max │ 37 │ 10.00 │ 200.00 │ 8265.03 │ 65.08 │ 41 │ 177 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ mutation │ 0.42 │ 0.00 │ 1.00 │ 1.31 │ 0.03 │ 9 │ 0.23 │ +│ mutation │ 0.16 │ 0.00 │ 1.00 │ 17.64 │ 0.14 │ 41 │ 0.41 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ crossover │ 0.66 │ 0.00 │ 1.00 │ 1.70 │ 0.04 │ 9 │ 0.54 │ +│ crossover │ 0.93 │ 0.00 │ 1.00 │ 42.41 │ 0.33 │ 41 │ 0.10 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ elitism │ -0.09 │ - │ - │ - │ - │ - │ 0.23 │ +│ elitism │ -0.09 │ - │ - │ - │ - │ - │ 0.49 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 81 │ 1.00 │ 100.00 │ 1404.93 │ 33.45 │ 9 │ 62 │ +│ max │ 30 │ 1.00 │ 100.00 │ 160.48 │ 1.26 │ 41 │ 31 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ population │ 116 │ 1.00 │ 1000.00 │ 9233.07 │ 219.83 │ 9 │ 3 │ +│ population │ 549 │ 1.00 │ 1000.00 │ 33602.75 │ 264.59 │ 41 │ 11 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 249 │ 100.00 │ 2000.00 │ 19863.18 │ 472.93 │ 9 │ 1486 │ +│ dynasties │ 439 │ 100.00 │ 2000.00 │ 58761.38 │ 462.69 │ 41 │ 1521 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -59,7 +63,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `level` : sudoku board difficulty level - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -73,19 +79,23 @@ - `final` : calculated value of parameter for which execution time was the lowest ## For SA: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 0 from 22 + - termination reason: NoImprovement + + - iterations number: 12 - - points from cache: 22 from 22 + - resumed after stale: 1 + + - points from cache: 31/32 - level: Easy - - execution time: 0.019s + - execution time: 0.026s - parameters: @@ -93,11 +103,11 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.8244 │ 0.00 │ 1.00 │ 0.48 │ 0.03 │ 12 │ 0.9554 │ +│ temperature │ 0.8244 │ 0.00 │ 1.00 │ 0.83 │ 0.03 │ 11 │ 0.9554 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 157 │ 10.00 │ 200.00 │ 261.00 │ 18.64 │ 12 │ 116 │ +│ max │ 157 │ 10.00 │ 200.00 │ 423.98 │ 17.67 │ 11 │ 116 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ @@ -111,14 +121,14 @@ │ elitism │ -0.00 │ - │ - │ - │ - │ - │ 0.00 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 67 │ 1.00 │ 100.00 │ 214.24 │ 15.30 │ 12 │ 39 │ +│ max │ 67 │ 1.00 │ 100.00 │ 265.64 │ 11.07 │ 11 │ 39 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ │ population │ 1 │ 1.00 │ 1.00 │ 0.00 │ 0.00 │ 0 │ 1 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 3455 │ 100.00 │ 5000.00 │ 13134.94 │ 938.21 │ 12 │ 1646 │ +│ dynasties │ 3455 │ 100.00 │ 5000.00 │ 17618.46 │ 734.10 │ 11 │ 1646 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -130,7 +140,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `level` : sudoku board difficulty level - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -144,19 +156,23 @@ - `final` : calculated value of parameter for which execution time was the lowest ## For GA: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 81 from 120 + - termination reason: NoImprovement + + - iterations number: 30 + + - resumed after stale: 4 - - points from cache: 39 from 120 + - points from cache: 87/93 - level: Easy - - execution time: 0.263s + - execution time: 0.175s - parameters: @@ -164,32 +180,32 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.6847 │ 0.00 │ 1.00 │ 0.45 │ 0.00 │ 36 │ 0.9995 │ +│ temperature │ 0.3698 │ 0.00 │ 1.00 │ 4.51 │ 0.05 │ 25 │ 0.9432 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 174 │ 10.00 │ 200.00 │ 514.31 │ 4.40 │ 36 │ 97 │ +│ max │ 108 │ 10.00 │ 200.00 │ 751.96 │ 8.74 │ 25 │ 109 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ mutation │ 0.78 │ 0.10 │ 1.00 │ 5.51 │ 0.05 │ 36 │ 0.22 │ +│ mutation │ 0.22 │ 0.10 │ 1.00 │ 4.71 │ 0.05 │ 25 │ 0.32 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ crossover │ 0.73 │ 0.10 │ 1.00 │ 2.09 │ 0.02 │ 36 │ 0.51 │ +│ crossover │ 0.16 │ 0.10 │ 1.00 │ 3.75 │ 0.04 │ 25 │ 0.54 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ elitism │ -0.52 │ - │ - │ - │ - │ - │ 0.26 │ +│ elitism │ 0.61 │ - │ - │ - │ - │ - │ 0.15 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 29 │ 1.00 │ 100.00 │ 134.61 │ 1.15 │ 36 │ 31 │ +│ max │ 61 │ 1.00 │ 100.00 │ 523.70 │ 6.09 │ 25 │ 35 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ population │ 846 │ 10.00 │ 2000.00 │ 24289.87 │ 207.61 │ 36 │ 84 │ +│ population │ 1743 │ 10.00 │ 2000.00 │ 29942.40 │ 348.17 │ 25 │ 12 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 859 │ 100.00 │ 2000.00 │ 8440.12 │ 72.14 │ 36 │ 1075 │ +│ dynasties │ 1626 │ 100.00 │ 2000.00 │ 10424.65 │ 121.22 │ 25 │ 1092 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -201,7 +217,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `level` : sudoku board difficulty level - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -221,11 +239,11 @@ │ │ coefficient │ per │ │ │ │ iterations │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ hybrid │ 0.9995 │ 108 │ 0.23 │ 0.54 │ 0.23 │ 62 │ 3 │ 1486 │ 0.154s │ +│ hybrid │ 1.0000 │ 177 │ 0.41 │ 0.10 │ 0.49 │ 31 │ 11 │ 1521 │ 0.117s │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ SA │ 0.9554 │ 116 │ 1.00 │ 0.00 │ 0.00 │ 39 │ 1 │ 1646 │ 0.019s │ +│ SA │ 0.9554 │ 116 │ 1.00 │ 0.00 │ 0.00 │ 39 │ 1 │ 1646 │ 0.026s │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ GA │ 0.9995 │ 97 │ 0.22 │ 0.51 │ 0.26 │ 31 │ 84 │ 1075 │ 0.263s │ +│ GA │ 0.9432 │ 109 │ 0.32 │ 0.54 │ 0.15 │ 35 │ 12 │ 1092 │ 0.175s │ └────────┴─────────────┴───────────┴──────────┴───────────┴─────────┴────────────┴────────────┴───────────┴───────────┘ ``` diff --git a/module/move/optimization_tools/tests/opt_params.rs b/module/move/optimization_tools/tests/opt_params.rs index ad4250ad9e..d50ffdba76 100644 --- a/module/move/optimization_tools/tests/opt_params.rs +++ b/module/move/optimization_tools/tests/opt_params.rs @@ -230,7 +230,9 @@ fn write_results " - `max number of iterations` : limit of total iterations of optimization process, termination condition\n", " - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition\n", " - `improvement threshold` : minimal value detected as improvement in objective function result\n", - " - `calculated points` : new calculated points that were not found in cache\n", + " - `termination reason` : the reason why optimization process was stopped\n", + " - `iterations number` : actual number of iterations performed during optimization\n", + " - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement\n", " - `points from cache` : points calculated during previous optimizations and read from cache\n", ); @@ -337,138 +339,76 @@ fn find_opt_params_sudoku() -> Result< (), Box< dyn std::error::Error > > let config = OptimalParamsConfig::default(); let initial = SudokuInitial::new( Board::from( easy ) ); - let hybrid_problem = Problem::new - ( - initial.clone(), - BestRowsColumnsCrossover, - RandomPairInBlockMutation, - ); - let starting_params = hybrid_optimizer::starting_params_for_hybrid()?; - let res = optimal_params_search::find_hybrid_optimal_params - ( - config.clone(), - starting_params.clone(), - hybrid_problem, - Some( path.clone() ), - ); - assert!( res.is_ok() ); - let mut hybrid_res = Statistics::new(); - if let Ok( solution ) = res - { - let cached = solution.stats.clone().unwrap().cached_points; - hybrid_res = Statistics - { - table_params : named_results_list - ( - solution.point.coords - .into_iter() - .map( | val | val ) - .collect_vec(), - solution.stats.unwrap(), - starting_params.bounds, - ), - list_params : vec! - [ - ( String::from( "max number of iterations" ), format!( "{}", config.max_iterations ) ), - ( String::from( "max no improvement iterations " ), format!( "{}", config.max_no_improvement_steps ) ), - ( String::from( "improvement threshold " ), format!( "{}s", config.improvement_threshold ) ), - ( String::from( "calculated points" ), format!( "{} from {}", cached.1, cached.1 + cached.0 ) ), - ( String::from( "points from cache" ), format!( "{} from {}", cached.0, cached.1 + cached.0 ) ), - ( String::from( "level" ), format!( "{:?}", Board::from( easy ).calculate_level() ) ), - ( String::from( "execution time" ), format!( "{:.3}s", solution.objective ) ), - ] - } - } - - // SA - let hybrid_problem = Problem::new - ( - initial.clone(), - BestRowsColumnsCrossover, - RandomPairInBlockMutation, - ); - let starting_params = hybrid_optimizer::starting_params_for_sa()?; - let res = optimal_params_search::find_hybrid_optimal_params - ( - config.clone(), - starting_params.clone(), - hybrid_problem, - Some( path.clone() ), - ); - assert!( res.is_ok() ); - let mut sa_res = Statistics::new(); - if let Ok( solution ) = res + let mut ga_res = Statistics::new(); + for mode in [ "hybrid", "sa", "ga" ] { - let cached = solution.stats.clone().unwrap().cached_points; - sa_res = Statistics + let mut starting_params = hybrid_optimizer::starting_params_for_hybrid()?; + match mode { - table_params : named_results_list - ( - solution.point.coords - .into_iter() - .map( | val | val ) - .collect_vec(), - solution.stats.unwrap(), - starting_params.bounds, - ), - list_params : vec! - [ - ( String::from( "max number of iterations" ), format!( "{}", config.max_iterations ) ), - ( String::from( "max no improvement iterations " ), format!( "{}", config.max_no_improvement_steps ) ), - ( String::from( "improvement threshold " ), format!( "{}s", config.improvement_threshold ) ), - ( String::from( "calculated points" ), format!( "{} from {}", cached.1, cached.1 + cached.0 ) ), - ( String::from( "points from cache" ), format!( "{} from {}", cached.0, cached.1 + cached.0 ) ), - ( String::from( "level" ), format!( "{:?}", Board::from( easy ).calculate_level() ) ), - ( String::from( "execution time" ), format!( "{:.3}s", solution.objective ) ), - ] + "hybrid" => {}, + "sa" => starting_params = hybrid_optimizer::starting_params_for_sa()?, + "ga" => starting_params = hybrid_optimizer::starting_params_for_ga()?, + _ => unreachable!(), } - } - // GA - let hybrid_problem = Problem::new( - initial.clone(), - BestRowsColumnsCrossover, - RandomPairInBlockMutation, - ); - let starting_params = hybrid_optimizer::starting_params_for_ga()?; - let res = optimal_params_search::find_hybrid_optimal_params - ( - config.clone(), - starting_params.clone(), - hybrid_problem, - Some( path ), - ); - assert!( res.is_ok() ); + let hybrid_problem = Problem::new + ( + initial.clone(), + BestRowsColumnsCrossover, + RandomPairInBlockMutation, + ); - let mut ga_res = Statistics::new(); - if let Ok( solution ) = res - { - let cached = solution.stats.clone().unwrap().cached_points; - ga_res = Statistics + let res = optimal_params_search::find_hybrid_optimal_params + ( + config.clone(), + starting_params.clone(), + hybrid_problem, + Some( path.clone() ), + ); + assert!( res.is_ok() ); + + if let Ok( solution ) = res { - table_params : named_results_list - ( - solution.point.coords - .into_iter() - .map( | val | val ) - .collect_vec(), - solution.stats.unwrap(), - starting_params.bounds, - ), - list_params : vec! - [ - ( String::from( "max number of iterations" ), format!( "{}", config.max_iterations ) ), - ( String::from( "max no improvement iterations " ), format!( "{}", config.max_no_improvement_steps ) ), - ( String::from( "improvement threshold " ), format!( "{}s", config.improvement_threshold ) ), - ( String::from( "calculated points" ), format!( "{} from {}", cached.1, cached.1 + cached.0 ) ), - ( String::from( "points from cache" ), format!( "{} from {}", cached.0, cached.1 + cached.0 ) ), - ( String::from( "level" ), format!( "{:?}", Board::from( easy ).calculate_level() ) ), - ( String::from( "execution time" ), format!( "{:.3}s", solution.objective ) ), - ] + assert!( solution.stats.is_some() ); + let stats = solution.stats.clone().unwrap(); + let cached = stats.cached_points; + let final_res = Statistics + { + table_params : named_results_list + ( + solution.point.coords + .into_iter() + .map( | val | val ) + .collect_vec(), + solution.stats.unwrap(), + starting_params.bounds, + ), + list_params : vec! + [ + ( String::from( "max number of iterations" ), format!( "{}", config.max_iterations ) ), + ( String::from( "max no improvement iterations " ), format!( "{}", config.max_no_improvement_steps ) ), + ( String::from( "improvement threshold " ), format!( "{}s", config.improvement_threshold ) ), + ( String::from( "termination reason" ), format!( "{}", solution.reason ) ), + ( String::from( "iterations number" ), format!( "{}", stats.number_of_iterations ) ), + ( String::from( "resumed after stale" ), format!( "{}", stats.resumed_after_stale ) ), + ( String::from( "points from cache" ), format!( "{}/{}", cached.0, cached.1 + cached.0 ) ), + ( String::from( "level" ), format!( "{:?}", Board::from( easy ).calculate_level() ) ), + ( String::from( "execution time" ), format!( "{:.3}s", solution.objective ) ), + ] + }; + + match mode + { + "hybrid" => hybrid_res = final_res, + "sa" => sa_res = final_res, + "ga" => ga_res = final_res, + _ => unreachable!(), + } } } + write_results( String::from( "sudoku_results" ), String::from( "Sudoku Problem" ), hybrid_res, sa_res, ga_res )?; Ok( () ) } diff --git a/module/move/optimization_tools/tsp_results.md b/module/move/optimization_tools/tsp_results.md index 78b5195456..22ec13075b 100644 --- a/module/move/optimization_tools/tsp_results.md +++ b/module/move/optimization_tools/tsp_results.md @@ -2,19 +2,19 @@ ## For hybrid: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 124 from 133 + - calculated points: 79 from 79 - - points from cache: 9 from 133 + - points from cache: 0 from 79 - number of nodes: 4 - - execution time: 0.008s + - execution time: 0.018s - parameters: @@ -22,32 +22,32 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.7726 │ 0.00 │ 1.00 │ 28.88 │ 0.21 │ 74 │ 0.7349 │ +│ temperature │ 0.8572 │ 0.00 │ 1.00 │ 0.14 │ 0.00 │ 50 │ 0.9999 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 14 │ 10.00 │ 200.00 │ 6917.13 │ 49.76 │ 74 │ 33 │ +│ max │ 150 │ 10.00 │ 200.00 │ 2920.64 │ 35.19 │ 50 │ 54 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ mutation │ 0.00 │ 0.00 │ 1.00 │ 23.18 │ 0.17 │ 74 │ 0.13 │ +│ mutation │ 0.57 │ 0.00 │ 1.00 │ 21.60 │ 0.26 │ 50 │ 0.02 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ crossover │ 0.63 │ 0.00 │ 1.00 │ 40.81 │ 0.29 │ 74 │ 0.86 │ +│ crossover │ 0.56 │ 0.00 │ 1.00 │ 17.49 │ 0.21 │ 50 │ 0.31 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ elitism │ 0.37 │ - │ - │ - │ - │ - │ 0.01 │ +│ elitism │ -0.13 │ - │ - │ - │ - │ - │ 0.66 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 58 │ 1.00 │ 100.00 │ 3695.03 │ 26.58 │ 74 │ 62 │ +│ max │ 35 │ 1.00 │ 100.00 │ 152.19 │ 1.83 │ 50 │ 30 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ population │ 674 │ 1.00 │ 1000.00 │ 46923.94 │ 337.58 │ 74 │ 1 │ +│ population │ 148 │ 1.00 │ 1000.00 │ 20174.02 │ 243.06 │ 50 │ 10 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 824 │ 100.00 │ 2000.00 │ 79548.00 │ 572.29 │ 74 │ 138 │ +│ dynasties │ 1982 │ 100.00 │ 2000.00 │ 63109.09 │ 760.35 │ 50 │ 130 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -59,7 +59,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `number of nodes` : number of nodes in graph representing cities from traveling salesman problem - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -73,15 +75,15 @@ - `final` : calculated value of parameter for which execution time was the lowest ## For SA: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 16 from 26 + - calculated points: 33 from 33 - - points from cache: 10 from 26 + - points from cache: 0 from 33 - number of nodes: 4 @@ -93,11 +95,11 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.4533 │ 0.00 │ 1.00 │ 0.28 │ 0.01 │ 12 │ 0.9997 │ +│ temperature │ 0.1471 │ 0.00 │ 1.00 │ 8.73 │ 0.35 │ 17 │ 1.0000 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 54 │ 10.00 │ 200.00 │ 397.21 │ 20.91 │ 12 │ 120 │ +│ max │ 112 │ 10.00 │ 200.00 │ 188.84 │ 7.55 │ 17 │ 110 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ @@ -111,14 +113,14 @@ │ elitism │ -0.00 │ - │ - │ - │ - │ - │ 0.00 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 91 │ 1.00 │ 100.00 │ 920.69 │ 48.46 │ 12 │ 87 │ +│ max │ 99 │ 1.00 │ 100.00 │ 1208.63 │ 48.35 │ 17 │ 100 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ │ population │ 1 │ 1.00 │ 1.00 │ 0.00 │ 0.00 │ 0 │ 1 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 2849 │ 100.00 │ 5000.00 │ 35258.61 │ 1855.72 │ 12 │ 117 │ +│ dynasties │ 808 │ 100.00 │ 5000.00 │ 38996.81 │ 1559.87 │ 17 │ 123 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -130,7 +132,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `number of nodes` : number of nodes in graph representing cities from traveling salesman problem - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -144,19 +148,19 @@ - `final` : calculated value of parameter for which execution time was the lowest ## For GA: - - max number of iterations: 100 + - max number of iterations: 50 - max no improvement iterations : 10 - improvement threshold : 0.005s - - calculated points: 40 from 67 + - calculated points: 51 from 58 - - points from cache: 27 from 67 + - points from cache: 7 from 58 - number of nodes: 4 - - execution time: 0.033s + - execution time: 0.036s - parameters: @@ -164,32 +168,32 @@ ┌─────────────┬────────┬────────┬─────────┬─────────────┬──────────┬─────────┬────────┐ │ │ start │ min │ max │ sum of diff │ expected │ changes │ final │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ temperature │ 0.9963 │ 0.00 │ 1.00 │ 0.05 │ 0.00 │ 35 │ 1.0000 │ +│ temperature │ 0.9963 │ 0.00 │ 1.00 │ 0.05 │ 0.00 │ 32 │ 1.0000 │ │ decrease │ │ │ │ │ │ │ │ │ coefficient │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 170 │ 10.00 │ 200.00 │ 4452.25 │ 71.81 │ 35 │ 18 │ +│ max │ 170 │ 10.00 │ 200.00 │ 2888.32 │ 53.49 │ 32 │ 24 │ │ mutations │ │ │ │ │ │ │ │ │ per │ │ │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ mutation │ 0.39 │ 0.10 │ 1.00 │ 7.29 │ 0.12 │ 35 │ 0.13 │ +│ mutation │ 0.39 │ 0.10 │ 1.00 │ 7.22 │ 0.13 │ 32 │ 0.10 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ crossover │ 0.81 │ 0.10 │ 1.00 │ 10.88 │ 0.18 │ 35 │ 0.29 │ +│ crossover │ 0.81 │ 0.10 │ 1.00 │ 8.82 │ 0.16 │ 32 │ 0.28 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ elitism │ -0.20 │ - │ - │ - │ - │ - │ 0.58 │ +│ elitism │ -0.20 │ - │ - │ - │ - │ - │ 0.61 │ │ rate │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ max │ 58 │ 1.00 │ 100.00 │ 1560.73 │ 25.17 │ 35 │ 28 │ +│ max │ 58 │ 1.00 │ 100.00 │ 1589.45 │ 29.43 │ 32 │ 100 │ │ stale │ │ │ │ │ │ │ │ │ iterations │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ population │ 572 │ 10.00 │ 2000.00 │ 44693.82 │ 720.87 │ 35 │ 19 │ +│ population │ 572 │ 10.00 │ 2000.00 │ 38470.00 │ 712.41 │ 32 │ 46 │ │ size │ │ │ │ │ │ │ │ ├─────────────┼────────┼────────┼─────────┼─────────────┼──────────┼─────────┼────────┤ -│ dynasties │ 1824 │ 100.00 │ 2000.00 │ 43273.64 │ 697.96 │ 35 │ 123 │ +│ dynasties │ 1824 │ 100.00 │ 2000.00 │ 34862.61 │ 645.60 │ 32 │ 115 │ │ limit │ │ │ │ │ │ │ │ └─────────────┴────────┴────────┴─────────┴─────────────┴──────────┴─────────┴────────┘ ``` @@ -201,7 +205,9 @@ - `max number of iterations` : limit of total iterations of optimization process, termination condition - `max no improvement iterations` : max amount of steps performed without detected improvement, termination condition - `improvement threshold` : minimal value detected as improvement in objective function result - - `calculated points` : new calculated points that were not found in cache + - `termination reason` : the reason why optimization process was stopped + - `iterations number` : actual number of iterations performed during optimization + - `resumed after stale` : how many times optimization progress was resumed after some iterations without improvement - `points from cache` : points calculated during previous optimizations and read from cache - `number of nodes` : number of nodes in graph representing cities from traveling salesman problem - `execution time` : duration of shortest found hybrid optimization process using final parameters, measured in seconds @@ -221,11 +227,11 @@ │ │ coefficient │ per │ │ │ │ iterations │ │ │ │ │ │ │ dynasty │ │ │ │ │ │ │ │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ hybrid │ 0.7349 │ 33 │ 0.13 │ 0.86 │ 0.01 │ 62 │ 1 │ 138 │ 0.008s │ +│ hybrid │ 0.9999 │ 54 │ 0.02 │ 0.31 │ 0.66 │ 30 │ 10 │ 130 │ 0.018s │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ SA │ 0.9997 │ 120 │ 1.00 │ 0.00 │ 0.00 │ 87 │ 1 │ 117 │ 0.007s │ +│ SA │ 1.0000 │ 110 │ 1.00 │ 0.00 │ 0.00 │ 100 │ 1 │ 123 │ 0.007s │ ├────────┼─────────────┼───────────┼──────────┼───────────┼─────────┼────────────┼────────────┼───────────┼───────────┤ -│ GA │ 1.0000 │ 18 │ 0.13 │ 0.29 │ 0.58 │ 28 │ 19 │ 123 │ 0.033s │ +│ GA │ 1.0000 │ 24 │ 0.10 │ 0.28 │ 0.61 │ 100 │ 46 │ 115 │ 0.036s │ └────────┴─────────────┴───────────┴──────────┴───────────┴─────────┴────────────┴────────────┴───────────┴───────────┘ ``` From 0a73f11af8c16d825da6ecc5e6135b64562ba5b3 Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Tue, 19 Mar 2024 17:56:02 +0200 Subject: [PATCH 2/6] +test --- .../optimization_tools/src/optimal_params_search/nelder_mead.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs index c379c7441f..ef7e16e19d 100644 --- a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs +++ b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs @@ -503,6 +503,7 @@ where R : RangeBounds< f64 > + Sync, let score = self.evaluate_point( &x, &mut stats ); res.push( ( x, score ) ); } + let mut iterations = 0; loop { From 995304d399e5919a04928fb3b3fa465df7961d7b Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Tue, 19 Mar 2024 18:15:29 +0200 Subject: [PATCH 3/6] !test --- .../optimization_tools/src/optimal_params_search/nelder_mead.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs index ef7e16e19d..c379c7441f 100644 --- a/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs +++ b/module/move/optimization_tools/src/optimal_params_search/nelder_mead.rs @@ -503,7 +503,6 @@ where R : RangeBounds< f64 > + Sync, let score = self.evaluate_point( &x, &mut stats ); res.push( ( x, score ) ); } - let mut iterations = 0; loop { From aabac5fb3932046ac04b6c46c6c05ed0f1236c4e Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Wed, 20 Mar 2024 14:00:27 +0200 Subject: [PATCH 4/6] fix derives --- module/move/optimization_tools/src/hybrid_optimizer/mod.rs | 2 +- .../move/optimization_tools/src/hybrid_optimizer/sim_anneal.rs | 2 +- module/move/optimization_tools/src/problems/sudoku/cell_val.rs | 2 +- module/move/optimization_tools/src/problems/sudoku/sudoku.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module/move/optimization_tools/src/hybrid_optimizer/mod.rs b/module/move/optimization_tools/src/hybrid_optimizer/mod.rs index ac91811d33..90f381f6b6 100644 --- a/module/move/optimization_tools/src/hybrid_optimizer/mod.rs +++ b/module/move/optimization_tools/src/hybrid_optimizer/mod.rs @@ -8,7 +8,7 @@ use iter_tools::Itertools; use std::ops::RangeInclusive; use rayon::iter::{ ParallelIterator, IndexedParallelIterator}; use deterministic_rand::{ Seed, seq::{ SliceRandom, IteratorRandom } }; -use derive_tools::Display; +use derive_tools::exposed::Display; use optimal_params_search::OptimalProblem; mod gen_alg; diff --git a/module/move/optimization_tools/src/hybrid_optimizer/sim_anneal.rs b/module/move/optimization_tools/src/hybrid_optimizer/sim_anneal.rs index 112760b289..c176729441 100644 --- a/module/move/optimization_tools/src/hybrid_optimizer/sim_anneal.rs +++ b/module/move/optimization_tools/src/hybrid_optimizer/sim_anneal.rs @@ -1,6 +1,6 @@ //! Implementation of Simulated Annealing for Hybrid Optimizer. -use derive_tools::{ FromInner, InnerFrom, Display }; +use derive_tools::{ FromInner, InnerFrom, exposed::Display }; /// Represents temperature of SA process. #[ derive( Default, Debug, Display, Clone, Copy, PartialEq, PartialOrd, FromInner, InnerFrom ) ] pub struct Temperature( f64 ); diff --git a/module/move/optimization_tools/src/problems/sudoku/cell_val.rs b/module/move/optimization_tools/src/problems/sudoku/cell_val.rs index f5b5394b95..f17b3db378 100644 --- a/module/move/optimization_tools/src/problems/sudoku/cell_val.rs +++ b/module/move/optimization_tools/src/problems/sudoku/cell_val.rs @@ -1,7 +1,7 @@ //! Contains CellVal structure that corresponds to single digit on Sudoku field. //! -use derive_tools::Display; +use derive_tools::exposed::Display; /// Represents the value of a cell in Sudoku. It can have a value from 1 to 9 or 0 if the cell is not assigned. #[ derive( Default, Debug, Display, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash ) ] diff --git a/module/move/optimization_tools/src/problems/sudoku/sudoku.rs b/module/move/optimization_tools/src/problems/sudoku/sudoku.rs index e71e3bb1d6..26b83e8e7b 100644 --- a/module/move/optimization_tools/src/problems/sudoku/sudoku.rs +++ b/module/move/optimization_tools/src/problems/sudoku/sudoku.rs @@ -4,7 +4,7 @@ use std::collections::HashSet; use crate::hybrid_optimizer::*; use crate::problems::sudoku::*; -use derive_tools::{ FromInner, InnerFrom, Display }; +use derive_tools::{ FromInner, InnerFrom, exposed::Display }; use deterministic_rand::{ Hrng, Rng, seq::SliceRandom }; use iter_tools::Itertools; From 974b76c535b32ef9ed52757b47b50cecd2b447c8 Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Mon, 1 Apr 2024 14:31:06 +0300 Subject: [PATCH 5/6] add patch +test --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b1594b7e6a..4ad9b88f5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -474,6 +474,6 @@ path = "module/test/c" default-features = true -# [patch.crates-io] -# pathfinder_geometry = { git = "https://github.com/servo/pathfinder.git" } -# pathfinder_simd = { git = "https://github.com/servo/pathfinder.git" } +[patch.crates-io] +pathfinder_geometry = { git = "https://github.com/servo/pathfinder.git" } +pathfinder_simd = { git = "https://github.com/servo/pathfinder.git" } From 6e220b9e9e368106fba63257ed09d5b2488a7a52 Mon Sep 17 00:00:00 2001 From: YuliaProkopovych Date: Thu, 25 Apr 2024 14:45:57 +0300 Subject: [PATCH 6/6] fix +test --- module/move/optimization_tools/Cargo.toml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/module/move/optimization_tools/Cargo.toml b/module/move/optimization_tools/Cargo.toml index a9fb722248..3f2473242e 100644 --- a/module/move/optimization_tools/Cargo.toml +++ b/module/move/optimization_tools/Cargo.toml @@ -48,15 +48,16 @@ rand = "0.8.5" statrs = "0.16.0" faer = { version = "0.16.0", features = [ "ndarray" ] } ndarray = "0.15.6" -plotters = { version = "0.3.5", default-features=false, features = [ - "bitmap_encoder", - "ttf", - "area_series", - "point_series", - "line_series", - "full_palette", - "bitmap_backend", -] } +plotters = { git = "https://github.com/plotters-rs/plotters.git" } +# plotters = { version = "0.3.5", default-features=false, features = [ +# "bitmap_encoder", +# "ttf", +# "area_series", +# "point_series", +# "line_series", +# "full_palette", +# "bitmap_backend", +# ] } plotters-backend = { version = "0.3.5", optional = true } piston_window = { version = "0.120.0", optional = true } exmex = { version = "0.18.0", features = [ "partial" ], optional = true }