File tree Expand file tree Collapse file tree
dynamicalgorithmselection/optimizers/EXAMPLE Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import numpy as np
2+
3+ from dynamicalgorithmselection .optimizers .Optimizer import Optimizer
4+
5+
6+ class IDENTITY (Optimizer ):
7+ """An optimizer that returns the same x, y it received — a no-op pass-through."""
8+
9+ def __init__ (self , problem , options ):
10+ Optimizer .__init__ (self , problem , options )
11+ self .n_individuals = 1
12+
13+ def optimize (self , fitness_function = None , args = None ):
14+ fitness = Optimizer .optimize (self , fitness_function )
15+ x = self .start_conditions .get ("x" , None )
16+
17+ if x is None :
18+ x = self .rng_initialization .uniform (
19+ self .initial_lower_boundary ,
20+ self .initial_upper_boundary ,
21+ )
22+
23+ while not self ._check_terminations ():
24+ self ._evaluate_fitness (x )
25+
26+ return self ._collect (fitness )
27+
28+ def _collect (self , fitness ):
29+ for i in range (1 , len (fitness )):
30+ if np .isnan (fitness [i ]):
31+ fitness [i ] = fitness [i - 1 ]
32+ results = Optimizer ._collect (self , fitness )
33+ return results
You can’t perform that action at this time.
0 commit comments