Problems¶
A Quick Look¶
Problems in PyGMO are objects, first constructed and then used in conjunction to an algorithm. The user can implement its own problem directly in Python, in which case he needs to inherit from PyGMO.problem.base or PyGMO.problem.base_stochastic class. You may see adding_a_new_optimization_problem or Adding a new stochastic optimization problem
Meta-problems¶
Common Name | Name in PyGMO | Comments |
---|---|---|
Rotated | PyGMO.problem.rotated | |
Shifted | PyGMO.problem.shifted | |
Normalized | PyGMO.problem.normalized | |
Noisy | PyGMO.problem.noisy | |
Decompose | PyGMO.problem.decompose | |
Death-penalty | PyGMO.problem.death_penalty | Minimization assumed. |
Constrained to MO | PyGMO.problem.con2mo | |
Constrained to Unconstrained | PyGMO.problem.con2uncon |
Box-Constrained Continuous Single-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
Ackley | PyGMO.problem.ackley | |
Bukin F6 | PyGMO.problem.bukin | A difficult bi-dimensional problem |
Branin | PyGMO.problem.branin | Bi-dimensional problem |
CEC2013 | PyGMO.problem.cec2013 | 28 problems part of CEC2013 Competition |
De Jong | PyGMO.problem.dejong | |
De Jong | PyGMO.problem.py_example | Implemented directly in Python |
Griewank | PyGMO.problem.griewank | |
Himmelblau | PyGMO.problem.himmelblau | Bi-dimensional problem |
Lennard-Jones | PyGMO.problem.lennard_jones | |
Michalewicz | PyGMO.problem.michalewicz | |
Rosenbrock | PyGMO.problem.rosenbrock | |
Rastrigin | PyGMO.problem.rastrigin | |
Schwefel | PyGMO.problem.schwefel | |
MGA-1DSM (tof encoding) | PyGMO.problem.mga_1dsm_tof | Requires the GTOP database option active |
MGA-1DSM (alpha encoding) | PyGMO.problem.mga_1dsm_alpha | Requires the GTOP database option active |
Cassini 1 | PyGMO.problem.cassini_1 | Requires the GTOP database option active |
Cassini 2 | PyGMO.problem.cassini_2 | Requires the GTOP database option active |
Rosetta | PyGMO.problem.rosetta | Requires the GTOP database option active |
Tandem | PyGMO.problem.tandem | Requires the GTOP database option active |
Laplace | PyGMO.problem.tandem | Requires the GTOP database option active |
Messenger (Full Problem) | PyGMO.problem.messenger_full | Requires the GTOP database option active |
GTOC1 | PyGMO.problem.gtoc_1 | Requires the GTOP database option active |
Sagas | PyGMO.problem.sagas | Requires the GTOP database option active |
Box-Constrained Continuous Multi-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
Kursawe’s study | PyGMO.problem.kur | |
Fonseca and Fleming’s study | PyGMO.problem.fon | |
Poloni’s study | PyGMO.problem.pol | |
Shaffer’s study | PyGMO.problem.sch | |
ZDT | PyGMO.problem.zdt | |
DTLZ | PyGMO.problem.dtlz | |
CEC2009 (UF1-UF10) | PyGMO.problem.cec2009 | UF problems from CEC2009 Competition. |
MGA-1DSM (tof encoding) | PyGMO.problem.mga_1dsm_tof | Requires the GTOP database option active |
MGA-1DSM (alpha encoding) | PyGMO.problem.mga_1dsm_alpha | Requires the GTOP database option active |
Cassini 1 | PyGMO.problem.cassini_1 | Requires the GTOP database option active |
Constrained Continuous Single-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
CEC2006 | PyGMO.problem.cec2006 | 24 problems part of CEC2006 Competition |
Pressure vessel design | PyGMO.problem.pressure_vessel | |
Welded beam design | PyGMO.problem.welded_beam | |
Tension compression string design | PyGMO.problem.tens_comp_string | |
Luksan Vlcek 1 | PyGMO.problem.luksan_vlcek_1 | |
Luksan Vlcek 2 | PyGMO.problem.luksan_vlcek_2 | |
Luksan Vlcek 3 | PyGMO.problem.luksan_vlcek_3 | |
Planet to Planet LT Transfer | PyGMO.problem.py_pl2pl | Requires PyKEP. Implemented in Python |
SNOPT Toy-Problem | PyGMO.problem.snopt_toyprob | |
GTOC2 (Full Problem) | PyGMO.problem.gtoc_2 | Requires the GTOP database option active |
Constrained Continuous Multi-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
CEC2009 (CF1-CF10) | PyGMO.problem.cec2009 | CF problems from CEC2009 Competition. |
Box-Constrained Integer Single-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
String Match | PyGMO.problem.string_match |
Constrained Integer Single-Objective¶
Common Name | Name in PyGMO | Comments |
---|---|---|
Golomb Ruler | PyGMO.problem.golomb_ruler | |
Traveling Salesman | PyGMO.problem.tsp |
Stochastic Objective Function¶
Common Name | Name in PyGMO | Comments |
---|---|---|
Inventory Problem | PyGMO.problem.inventory | |
MIT SPHERES | PyGMO.problem.mit_spheres | |
Noisy De Jong | PyGMO.problem.py_example_stochastic |
Detailed Documentation¶
- class PyGMO.problem.base¶
- base.__init__(*args)¶
Base problem constructor. It must be called from within the derived class constructor __init__()
USAGE: super(derived_class_name,self).__init__(dim, i_dim, n_obj, c_dim, c_ineq_dim, c_tol)
- dim: Total dimension of the decision vector
- i_dim: dimension of the integer part of decision vector (the integer part is placed at the end of the decision vector). Defaults to 0
- n_obj: number of objectives. Defaults to 1
- c_dim: total dimension of the constraint vector. dDefaults to 0
- c_ineq_dim: dimension of the inequality part of the constraint vector (inequality const. are placed at the end of the decision vector). Defaults to 0
- c_tol: constraint tolerance. When comparing individuals, this tolerance is used to decide whether a constraint is considered satisfied.
- base.best_x¶
Best known decision vector(s).
- base.best_f¶
Best known fitness vector(s).
- base.best_c¶
Best known constraints vector(s).
- base.dimension¶
Global dimension.
- base.f_dimension¶
Fitness dimension.
- base.i_dimension¶
Integer dimension.
- base.c_dimension¶
Global constraints dimension.
- base.ic_dimension¶
Inequality constraints dimension.
- base.c_tol¶
Tolerance used in constraints analysis.
- _objfun_impl(self, x)¶
This is a virtual function tham must be re-implemented in the derived class and must return a tuple packing as many numbers as the problem objectives (n_obj)
- _compute_constraints_impl(self, x)¶
This is a virtual function that can be re-implemented in the derived class (if c_dim>0) and must return a tuple packing as many numbers as the declared dimension of the problem constraints (c_dim). Inequality constarints need to be packed at last.
- _compare_fitness_impl(self, f1, f2)¶
This is a virtual function that can be re-implemented in the derived class and must return a boolean value. Return true if f1 Pareto dominate f2, false otherwise. The default implementation will assume minimisation for each one of the f components i.e., each pair of corresponding elements in f1 and f2 is compared: if all elements in f1 are less or equal to the corresponding element in f2 (and at least one is less), true will be returned. Otherwise, false will be returned.
- _compare_constraints_impl(self, c1, c2)¶
This is a virtual function tham can be re-implemented in the derived class (if c_dim>0) and must return a boolean value. Return true if c1 is a strictly better constraint vector than c2, false otherwise. Default implementation will return true under the following conditions, tested in order: c1 satisfies more constraints than c2, c1 and c2 satisfy the same number of constraints and the L2 norm of the constraint mismatches for c1 is smaller than for c2. Otherwise, false will be returned.
- _compare_fc_impl(self, f1, c1, f2, c2)¶
This is a virtual function that can be re-implemented in the derived class (if c_dim>0) and must return a boolean value. By default, the function will perform sanity checks on the input arguments and will then call _compare_constraints_impl() if the constraint dimensions is not null, _compare_fitness_impl() otherwise.
- base.reset_caches((_base)arg1) → None :¶
Resets the internal caching system of PyGMO that stores previos calls to the objective function/ constraint function. This method should be called whenever a problem object is changed and the change affects the objective function.
- base.set_bounds((_base)arg1, (float)arg2, (float)arg3) → None :¶
- Set all bounds to the input values.
- set_bounds( (_base)arg1, (object)arg2, (object)arg3) -> None :
- Set bounds to the input vectors.
- base.feasibility_x((_base)arg1, (object)arg2) → bool :¶
Determine feasibility of decision vector.
- base.feasibility_c((_base)arg1, (object)arg2) → bool :¶
Determine feasibility of constraint vector.
- class PyGMO.problem.death_penalty¶
- death_penalty.__init__(problem=None, method=None, penalty_factors=None)¶
Implements a meta-problem class that wraps some other constrained problems, resulting in death penalty constraints handling. Three implementations of the death penalty are available. The first one is the most common simple death penalty. The second one is the death penalty defined by Angel Kuri Morales et al. (Kuri Morales, A. and Quezada, C.C. A Universal eclectic genetic algorithm for constrained optimization, Proceedings 6th European Congress on Intelligent Techniques & Soft Computing, EUFIT‘98, 518-522, 1998.) Simple death penalty penalizes the fitness function with a high value, Kuri method penalizes the fitness function according to the rate of satisfied constraints. The third one is a weighted static penalization. It penalizes the objective with the sum of the constraints violation, each one penalized with a given factor.
USAGE: problem.death_penalty(problem=PyGMO.cec2006(4), method=death_penalty.method.SIMPLE)
- problem: PyGMO constrained problem one wants to treat with a death penalty approach
- method: Simple death method set with SIMPLE, Kuri method set with KURI, weighted static penalization with WEIGHTED
- class PyGMO.problem.con2mo¶
- con2mo.__init__(problem=None, method='obj_cstrsvio')¶
Transforms a constrained problem into a multi-objective problem
Three implementations of the constrained to multi-objective are available. 1) ‘obj_cstrs’: The multi-objective problem is created with two objectives. The first objective is the same as that of the input problem, the second is the number of constraint violated 2) ‘obj_cstrsvio’: The multi-objective problem is created with two objectives. The first objective is the same as that of the input problem, the second is the norm of the total constraint violation 3) ‘obj_eqvio_ineqvio’: 2) ‘obj_cstrsvio’: The multi-objective problem is created with three objectives. The first objective is the same as that of the input problem, the second is the norm of the total equality constraint violation, the third is the norm of the total inequality constraint violation.
USAGE: problem.con2mo(problem=PyGMO.cec2006(4), method=’obj_cstrsvio’)
- problem: original PyGMO constrained problem
- method: one of ‘obj_cstrsvio’, ‘obj_eqvio_ineqvio’, ‘obj_cstrs’
- class PyGMO.problem.con2uncon¶
- con2uncon.__init__(problem=Problem name: CEC2006 - g4
- Global dimension: 5
- Integer dimension: 0
- Fitness dimension: 1
- Constraints dimension: 6
- Inequality constraints dimension: 6
- Lower bounds: [78, 33, 27, 27, 27, ... ]
- Upper bounds: [102, 45, 45, 45, 45, ... ]
- Constraints tolerance: [0, 0, 0, 0, 0, ... ]
- , method='optimality')
Implements a meta-problem class that wraps constrained problems, resulting in an unconstrained problem. Two methods are available for definig the objective function of the meta-problem: ‘optimality’ and ‘feasibility’. The ‘optimality’ uses as objective function the original objective function, it basically removes the constraints from the original problem. The ‘feasibility’ uses as objective function the sum of the violation of the constraints, the meta-problem hence optimize just the level of infeasibility.
Implements a meta-problem class that wraps some other constrained problems, resulting in multi-objective problem.
USAGE: problem.con2uncon(problem=PyGMO.cec2006(4), method=’optimality’)
- problem: original PyGMO constrained problem
- method: one of ‘optimality’, ‘feasibility’.
- class PyGMO.problem.shifted¶
- shifted.__init__(problem=None, shift=None)¶
Shifts a problem.
- NOTE: this meta-problem constructs a new problem where the objective function will be f(x+b),
- where b is the shift (bounds are also chaged accordingly)
USAGE: problem.shifted(problem=PyGMO.ackley(1), shift = a random vector)
- problem: PyGMO problem one wants to shift
- shift: a value or a list containing the shifts. By default, a radnom shift is created within the problem bounds
- shift_vector¶
The shift vector defining the new problem
- deshift((tuple) x)¶
Returns the de-shifted decision vector
- class PyGMO.problem.rotated¶
- rotated.__init__(problem=None, rotation=None)¶
Rotates a problem. (also reflections are possible) The new objective function will be f(Rx_{normal}), where R is an orthogonal matrix and x_{normal} is the decision vector normailized to [-1,1]
NOTE: To ensure all of the original space is included in the new box-constrained search space, bounds of the normalized variables are expanded to [-sqrt(2),sqrt(2)]. It is still guaranteed theat the original objective function will not be called outside of the original bounds by projecting points outside the original space onto the boundary
USAGE: problem.rotated(problem=PyGMO.ackley(1), rotation = a random orthogonal matrix)
- problem: PyGMO problem one wants to rotate
- rotation: a list of lists (matrix). If not specified, a random orthogonal matrix is used.
- rotation¶
The rotation matrix defining the new problem
- derotate((tuple) x)¶
Returns the de-rotated decision vector
- class PyGMO.problem.noisy¶
- noisy.__init__(problem=None, trials=1, param_first=0.0, param_second=1.0, noise_type=PyGMO.problem._problem_meta._noise_distribution.NORMAL, seed=0)¶
Inject noise to a problem. The new objective function will become stochastic, influence by a normally distributed noise.
USAGE: problem.noisy(problem=PyGMO.ackley(1), trials = 1, param_first=0.0, param_second=1.0, noise_type = problem.noisy.noise_distribution.NORMAL, seed=0)
- problem: PyGMO problem on which one wants to add noises
- trials: number of trials to average around
- param_first: Mean of the Gaussian noise / Lower bound of the uniform noise
- param_second: Standard deviation of the Gaussian noise / Upper bound of the uniform noise
- noise_type: Whether to inject a normally distributed noise or uniformly distributed noise
- seed: Seed for the underlying RNG
- class PyGMO.problem.normalized¶
- normalized.__init__(problem=None)¶
Normalizes a problem (e.g. maps all variables to [-1,1])
NOTE: this meta-problem constructs a new problem having normalized bounds/variables
USAGE: problem.normalized(problem=PyGMO.ackley(1))
- problem: PyGMO problem one wants to normalize
- denormalize((tuple) x)¶
Returns the de-normalized decision vector
- class PyGMO.problem.decompose¶
- decompose.__init__(problem=None, method='tchebycheff', weights=, []z=[])¶
Implements a meta-problem class resulting in a decomposed version of the multi-objective input problem, i.e. a single-objective problem having as fitness function some kind of combination of the original fitness functions.
NOTE: this meta-problem constructs a new single-objective problem
USAGE: problem.decompose(problem=PyGMO.zdt(1, 2), method = ‘tchebycheff’, weights=a random vector (summing to one), z= a zero vector)
- problem: PyGMO problem one wants to decompose
- method: the decomposition method to use (‘weighted’, ‘tchebycheff’ or ‘bi’)
- weights: the weight vector to build the new fitness function
- z: the reference point (used in TCHEBYCHEFF and BI methods)
- weights¶
The weights vector
- WEIGHTED¶
Weighted decomposition method
- TCHEBYCHEFF¶
Tchebycheff decomposition method
- BI¶
Boundary Intersection decomposition method
- class PyGMO.problem.ackley¶
- ackley.__init__(dim=10)¶
Constructs a Ackley problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.ackley(dim=10)
- dim: problem dimension
- class PyGMO.problem.bukin¶
- bukin.__init__()¶
Constructs a Bukin’s f6 problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.bukin()
- class PyGMO.problem.cec2006¶
- cec2006.__init__(prob_id=1)¶
Constructs one of the 24 CEC2006 Competition Problems (Constrained Continuous Single-Objective)
USAGE: problem.cec2006(prob_id=1)
- prob_id: Problem number, one of [1,2,...24]
- class PyGMO.problem.pressure_vessel¶
- pressure_vessel.__init__()¶
Constructs a pressure vessel design problem (Constrained Continuous Single-Objective)
USAGE: problem.pressure_vessel()
- class PyGMO.problem.welded_beam¶
- welded_beam.__init__()¶
Constructs a welded beam design problem (Constrained Continuous Single-Objective)
USAGE: problem.welded_beam()
- class PyGMO.problem.tens_comp_string¶
- tens_comp_string.__init__()¶
Constructs a tension compression string design problem (Constrained Continuous Single-Objective)
USAGE: problem.tens_comp_string()
- class PyGMO.problem.cec2009¶
- cec2009.__init__(prob_id=1, dim=30, is_constrained=False)¶
Constructs one of the 20 CEC2009 Competition Problems (Constrained / Unconstrained Multi-Objective)
USAGE: problem.cec2009(prob_id=1, dim=30, is_constrained=False)
- prob_id: Problem number, one of [1,2,...10]
- dim: Problem’s dimension (default is 30, corresponding to the competition set-up)
- is_constrained: if True constructs the CF problems, otherwise the UF (constrained/unconstrained)
- class PyGMO.problem.cec2013¶
- cec2013.__init__(prob_id=1, dim=10, path='input_data/')¶
Constructs one of the 28 CEC2013 Competition Problems (Box-Constrained Continuous Single-Objective)
NOTE: this problem requires two files to be put in the path indicated: “M_Dxx.txt” and “shift_data.txt”. These files can be downloaded from the CEC2013 competition site: http://web.mysites.ntu.edu.sg/epnsugan/PublicSite/Shared%20Documents/CEC2013/cec13-c-code.zip
USAGE: problem.cec2013(dim = 10, prob_id=1, path=”input_data/”)
- prob_id: Problem number, one of [1,2,...10]
- dim: Problem’s dimension (default is 10)
- path: Whether the problem is constrained or unconstrained
- class PyGMO.problem.rosenbrock¶
- rosenbrock.__init__(dim=10)¶
Constructs a Rosenbrock problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.rosenbrock(dim=10)
- dim: problem dimension
- class PyGMO.problem.string_match¶
- string_match.__init__(string='Can we use it for space?')¶
Constructs a string-match problem (Box-Constrained Integer Single-Objective)
NOTE: This is the problem of matching a string. Transcribed as an optimization problem
USAGE: problem.string_match(string = “mah”)
- string: string to match
- PyGMO.problem.pretty(x)¶
Returns a string decoding the chromosome
- class PyGMO.problem.rastrigin¶
- rastrigin.__init__(dim=10)¶
Constructs a Rastrigin problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.rastrigin(dim=10)
- dim: problem dimension
- class PyGMO.problem.schwefel¶
- schwefel.__init__(dim=10)¶
Constructs a Schwefel problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.schwefel(dim=10)
- dim: problem dimension
- class PyGMO.problem.dejong¶
- dejong.__init__(dim=10)¶
Constructs a De Jong problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.dejong(dim=10)
- dim: problem dimension
- class PyGMO.problem.griewank¶
- griewank.__init__(dim=10)¶
Constructs a De Jong problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.dejong(dim=10)
- dim: problem dimension
- class PyGMO.problem.lennard_jones¶
- lennard_jones.__init__(n_atoms=4)¶
Constructs a Lennard-Jones problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.lennard_jones(n_atoms=4)
- n_atoms: number of atoms
- class PyGMO.problem.branin¶
- branin.__init__()¶
Constructs a Branin problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.branin()
- class PyGMO.problem.himmelblau¶
- himmelblau.__init__()¶
Constructs a Himmelblau problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.himmelblau()
- class PyGMO.problem.michalewicz¶
- michalewicz.__init__(dim=10)¶
Constructs a Michalewicz problem (Box-Constrained Continuous Single-Objective)
USAGE: problem.michalewicz(dim=5)
NOTE: Minimum is -4.687 for dim=5 and -9.66 for dim = 10
- dim: problem dimension
- class PyGMO.problem.kur¶
- kur.__init__(dim=10)¶
Constructs a Kursawe’s study problem (Box-Constrained Continuous Multi-Objective)
NOTE: K Deb, A Pratap, S Agarwal: A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on, 2002
USAGE: problem.kur(dim = 10)
- dim: problem dimension
- class PyGMO.problem.fon¶
- fon.__init__()¶
Constructs a Fonseca and Fleming’s study problem (Box-Constrained Continuous Multi-Objective)
NOTE: K Deb, A Pratap, S Agarwal: A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on, 2002
USAGE: problem.fon()
- class PyGMO.problem.pol¶
- pol.__init__()¶
Constructs a Poloni’s study study problem (Box-Constrained Continuous Multi-Objective)
NOTE: K Deb, A Pratap, S Agarwal: A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on, 2002
USAGE: problem.pol()
- class PyGMO.problem.sch¶
- sch.__init__()¶
Constructs a Schaffer’s study problem (Box-Constrained Continuous Multi-Objective)
NOTE: K Deb, A Pratap, S Agarwal: A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on, 2002
USAGE: problem.sch()
- class PyGMO.problem.zdt¶
- zdt.__init__(prob_id=1, param_1=None)¶
Constructs a multi-objective box-constrained problem from the ZDT testsuite
NOTE: K Deb, A Pratap, S Agarwal: A fast and elitist multiobjective genetic algorithm: NSGA-II, IEEE Transactions on, 2002
USAGE: problem.zdt(prob_id = 1, param_1 = 30)
- prob_id: Problem number, one of [1,2,...6]
- param_1: problem dimension for all ZDT problems except ZDT5 (here it is the number of binary strings used)
- zdt.p_distance((zdt)arg1, (object)arg2) → float :¶
The p distance is a convergence metric measuring the distance of a population or individual from the pareto front. It is typically 0.0 if the individuals lie on the Pareto-front.
USAGE: x = prob.p_distance(pop) USAGE: x = prob.p_distance(x)
- pop: population to evaluate
- x: chromosome to evaluate
p_distance( (zdt)arg1, (population)arg2) -> float
- class PyGMO.problem.dtlz¶
- dtlz.__init__(prob_id=1, k=None, fdim=3, alpha=100)¶
- Constructs a multi-objective box-constrained problem from the DTLZ testsuite
NOTE: K Deb, L Thiele, M Laumanns, E Zitzler, Scalable test problems for evolutionary multiobjective optimization
USAGE: problem.dtlz(prob_id = 1, k = 20, fdim = 4)
- prob_id: Problem number, one of [1,2,...7]
- k: paramter defining integer dimension of the problem: k + fdim - 1
- fdim: number of objectives
- alpha: controls density of solutions (just used for prob_id = 4)
- dtlz.p_distance((dtlz)arg1, (object)arg2) → float :¶
The p distance is a convergence metric measuring the distance of a population or individual from the pareto front. It is typically 0.0 if the individuals lie on the Pareto-front.
USAGE: x = prob.p_distance(pop) USAGE: x = prob.p_distance(x)
- pop: population to evaluate
- x: chromosome to evaluate
p_distance( (dtlz)arg1, (population)arg2) -> float
- dtlz.plot(pop, a=40, comp=[0, 1, 2])¶
Generic plot-method for multi-objective optimization problems with more then 2 objectives
USAGE: prob.plot(pop, comp[0,2,3]) * pop: population of solutions to the problem * a: angle of view on which the 3d-plot is created * comp: indexes the fitness dimension for x,y and z axis in that order
- class PyGMO.problem.tsp¶
- tsp.__init__(weights=[[0, 1, 2], [1, 0, 5], [2, 5, 0]], type='cities')¶
Constructs Travelling Salesman Problem (TSP or ATSP) The problem encoding can be of three different types as selected by the type kwarg
1-“cities” This encoding represents the ids of the cities visited directly in the chromosome. It will thus create a constrained problem as only permutation of the cities ids are valid (e.g. [0,2,1,5,0] is not a valid chromosome)
2-“randomkeys” This encoding, first introduced in the paper Bean, J. C. (1994). Genetic algorithms and random keys for sequencing and optimization. ORSA journal on computing, 6(2), 154-160. It creates a box constrained problem without any constraint. It essentially represents the tour as a sequence of doubles bounded in [0,1]. The tour is reconstructed by the argsort of the sequence. (e.g. [0.34,0.12,0.76,0.03] -> [3,1,0,2])
3-“full” In the full encoding the TSP is represented as a integer linear programming problem. The details can be found in http://en.wikipedia.org/wiki/Travelling_salesman_problem Constructs a Travelling Salesman problem (Constrained Integer Single-Objective)
USAGE: problem.tsp(weights = [0,1,2],[1,0,5],[2,5,0], type=”randomkeys”)
- weights: Square matrix with zero diagonal entries containing the cities distances.
- type: encoding type. One of “cities”,”randomkeys”,”full”
- class PyGMO.problem.golomb_ruler¶
- golomb_ruler.__init__(order=5, length=10)¶
Constructs a Golomb Ruler problem (Constrained Integer Single-Objective)
NOTE: see http://en.wikipedia.org/wiki/Golomb_ruler
USAGE: problem.golomb_ruler(order = 5, length=10)
- order: order of the Golomb ruler
- length: length of the Golomb ruler
- class PyGMO.problem.luksan_vlcek_1¶
- luksan_vlcek_1.__init__(dim=3)¶
Constructs the first Luksan Vlcek problem (Constrained Continuous Single-Objective)
NOTE: L. Luksan and J. Vlcek, “Sparse and Parially Separable Test Problems for Unconstrained and Equality Constrained Optimization”
USAGE: problem.luksan_vlcek_1(dim=3)
- dim: problem dimension
- class PyGMO.problem.luksan_vlcek_2¶
- luksan_vlcek_2.__init__(dim=16)¶
Constructs the second Luksan Vlcek problem (Constrained Continuous Single-Objective)
NOTE: L. Luksan and J. Vlcek, “Sparse and Parially Separable Test Problems for Unconstrained and Equality Constrained Optimization”
USAGE: problem.luksan_vlcek_2(dim=16)
- dim: problem dimension
- class PyGMO.problem.luksan_vlcek_3¶
- luksan_vlcek_3.__init__(dim=8)¶
Constructs the third Luksan Vlcek problem (Constrained Continuous Single-Objective)
NOTE: L. Luksan and J. Vlcek, “Sparse and Parially Separable Test Problems for Unconstrained and Equality Constrained Optimization”
USAGE: problem.luksan_vlcek_3(dim=8)
- dim: problem dimension
- class PyGMO.problem.snopt_toyprob¶
- snopt_toyprob.__init__()¶
Constructs SNOPT toy-problem (Box-Constrained Continuous Multi-Objective)
USAGE: problem.snopt_toyprob()
- class PyGMO.problem.inventory¶
- inventory.__init__(weeks=4, sample_size=10, seed=0)¶
Constructs an Inventory Problem (Stochastic Objective Function)
NOTE: see www2.isye.gatech.edu/people/faculty/Alex_Shapiro/SPbook.pdf
USAGE: problem.inventory(weeks = 4, sample_size = 10, seed = 0):
- week: dimension of the problem corresponding to the numer of weeks
to plan the inventory for.
sample_size: dimension of the sample used to approximate the expected value
- seed: integer used as starting random seed to build the
pseudorandom sequences used to generate the sample
- class PyGMO.problem.mit_spheres¶
- mit_spheres.__init__(sample_size=10, n_hidden=10, ode_prec=0.001, seed=0, symmetric=False, simulation_time=50.0, sides=[0.6, 0.7, 0.8])¶
Construct a Neurocontroller Evolution problem that seeks to drive three point masses to form a triangle This problem was used to design a contorller for the MIT SPHERES test bed on boear the ISS
USAGE: problem.mit_spheres(sample_size = 10, n_hidden = 10, ode_prec = 1E-3, seed = 0, symmetric = False, simulation_time = 50.0):
- sample_size: number of initial conditions the neurocontroller is tested from
- n_hidden: number of hidden for the feed-forward neural network
- ode_prec: relative numerical precision of neurons the ODE integrator
- seed: integer used as starting random seed to build the pseudorandom sequences used to generate the sample
- symmetric: when True activates a Neural Network having symmetric weights (i.e. purely homogeneuos agents)
- simulation_time: when True activates a Neural Network having symmetric weights (i.e. purely homogeneuos agents)
- sides: sides of the triangle
- post_evaluate((tuple) x, (int) N, (int) seed) → (tuple) out¶
Returns a tuple with the N post evaluation results of chromosome x w.r.t. conditions generated by seed. The returned tuple has the structure [ic, fit] and is sorted by fit. Where ic are the initial conditions and fit the Evaluated fitness.
- simulate((tuple) x, (tuple) ic, (int) N) → (tuple) world_states¶
Returns the SPHERES coordinates as evaluated in one simulation with initial conditions ic and in N points
- visualize((tuple) world_states)¶
Requires VPython installed. It opens a graphical display and animate the motion of the three SPHERES as desribed by the world_state tuple (output from the simulate method)
- class PyGMO.problem.mga_1dsm_tof¶
- __init__(seq, t0, tof, vinf, multi_objective=False, add_vinf_dep=False, add_vinf_arr=True)¶
Constructs an mga_1dsm problem (tof-encoding)
- seq: list of PyKEP planets defining the encounter sequence, including the starting planet (default: earth venus earth)
- t0: list of two epochs defining the launch window (default: 2000-Jan-01 00:00:00 to 2002-Sep-27 00:00:00)
- tof: list of intervals defining the times of flight in days (default: [[50,900],[50,900]])
- vinf: list of two floats defining the minimum and maximum allowed initial hyperbolic velocity at launch in km/sec (default: [0.5, 2.5])
- multi_objective: when True constructs a multiobjective problem (dv, T)
- add_vinf_dep: when True the computed Dv includes the initial hyperbolic velocity (at launch)
- add_vinf_arr: when True the computed Dv includes the final hyperbolic velocity (at arrival)
USAGE: problem.mga_1dsm(seq = [planet_ss(‘earth’),planet_ss(‘venus’),planet_ss(‘earth’)], t0 = [epoch(0),epoch(1000)], tof = [ [200, 700], [200, 700] ], vinf = [0.5, 2.5], multi_objective = False, add_vinf_dep = False, add_vinf_arr = True)
- mga_1dsm_tof.plot(x)¶
Plots the trajectory represented by the decision vector x
- set_tof(tof)¶
Resets the tof-bounds by the provided list of epochs. Needs a list consisting of lower/upper bound tuples.
- set_launch_window((tuple) t0)¶
Resets the launch windows to the lower and upper bounds given by tuple t0. Bounds need to be epochs.
- set_vinf((double) vinf_u)¶
Sets the upper bound for vinf to vinf_u
- pretty((tuple) x) → (string) out¶
Returns a string with informations about tour encoded by x
- class PyGMO.problem.mga_1dsm_alpha¶
- __init__(seq, t0, tof, vinf, multi_objective=False, add_vinf_dep=False, add_vinf_arr=True)¶
Constructs an mga_1dsm problem (alpha-encoding)
- seq: list of PyKEP planets defining the encounter sequence, including the starting planet (default: earth venus earth)
- t0: list of two epochs defining the launch window (default: 2000-Jan-01 00:00:00 to 2002-Sep-27 00:00:00)
- tof: list of two floats defining the minimum and maximum allowed mission length in days (default: [365.25, 1826.35])
- vinf: list of two floats defining the minimum and maximum allowed initial hyperbolic velocity at launch in km/sec (default: [0.5, 2.5])
- multi_objective: when True constructs a multiobjective problem (dv, T)
- add_vinf_dep: when True the computed Dv includes the initial hyperbolic velocity (at launch)
- add_vinf_arr: when True the computed Dv includes the final hyperbolic velocity (at arrival)
USAGE: problem.mga_1dsm(seq = [planet_ss(‘earth’),planet_ss(‘venus’),planet_ss(‘earth’)], t0 = [epoch(0),epoch(1000)], tof = [ [200, 700], [200, 700] ], vinf = [0.5, 2.5], multi_objective = False, add_vinf_dep = False, add_vinf_arr = True)
- mga_1dsm_alpha.plot(x)¶
Plots the trajectory represented by the decision vector x
- set_tof((tuple) tof)¶
Resets the tof-bounds by the provided tuple of epochs.
- set_launch_window((tuple) t0)¶
Resets the launch windows to the lower and upper bounds given by tuple t0. Bounds need to be epochs.
- set_vinf((double) vinf_u)¶
Sets the upper bound for vinf to vinf_u
- pretty((tuple) x) → (string) out¶
Returns a string with informations about tour encoded by x
- class PyGMO.problem.cassini_1¶
- cassini_1.__init__(objectives=1)¶
Constructs a Cassini 1 Problem (Box-Constrained Continuous Single-Objective)
- NOTE: This problem (MGA) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
- Its single objective version has a global minimum at 4.9307 [km/s], and it is a deceptive problem with a larger minimum at 5.303 [km/s]
USAGE: problem.cassini_1(objectives = 1)
- objectives: number of objectives. 1=DV, 2=DV,DT
- class PyGMO.problem.cassini_2¶
- cassini_2.__init__()¶
Constructs a Cassini 2 Problem (Box-Constrained Continuous Single-Objective)
- NOTE: This problem (MGA-1DSM) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
It models the same interplanetary trajectory as the cassini_1 problem, but in a more accurate fashion, allowing deep space manouvres
Best known global minimum is at 8.383 [km/s]
USAGE: problem.cassini_2()
- class PyGMO.problem.messenger_full¶
- messenger_full.__init__()¶
Constructs a Mesenger Full Problem (Box-Constrained Continuous Single-Objective)
NOTE: This problem (MGA-1DSM) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
Best known global minimum is at 2.113USAGE: problem.messenger_full()
- class PyGMO.problem.rosetta¶
- rosetta.__init__()¶
Constructs a Rosetta Problem (Box-Constrained Continuous Single-Objective)
NOTE: This problem (MGA-1DSM) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
Best known global minimum is at 1.343 [km/s]USAGE: problem.rosetta()
- class PyGMO.problem.laplace¶
- laplace.__init__(seq=[3, 2, 3, 3, 5])¶
Constructs a EJSM-Laplace Problem (Box-Constrained Continuous Single-Objective)
- NOTE: This problem (MGA-1DSM) is similar to TandEM, but targets Jupiter and the user
- can specify explicitly the planetary fly-by sequence
USAGE: problem.laplace(seq = [3,2,3,3,5])
- seq: The planetary sequence. This is a list of ints that represent the planets to visit
1 - Mercury, 2 - Venus, 3 - Earth, 4 - Mars, 5 - Jupiter, 6 - Saturn. It must start from 3 (Earth) and end with 5 (Jupiter)
- class PyGMO.problem.tandem¶
- tandem.__init__(prob_id=7, max_tof=-1)¶
Constructs a TandEM Problem (Box-Constrained Continuous Single-Objective)
NOTE: This problem (MGA-1DSM) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]. The objective function is -log(m_final).
USAGE: problem.tandem(prob_id = 7, max_tof = -1)
- prob_id: Selects the problem variant (one of 1..25). All problems differ from the fly-by sequence
- max_tof = Activates a constriants on the maximum time of flight allowed (in years)
- class PyGMO.problem.gtoc_1¶
- gtoc_1.__init__()¶
Constructs a GTOC 1 Problem (Box-Constrained Continuous Single-Objective)
NOTE: This problem (MGA) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
Best known global minima is at -1,581,950USAGE: problem.gtoc_1()
- class PyGMO.problem.gtoc_2¶
- gtoc_2.__init__(ast1=815, ast2=300, ast3=110, ast4=47, n_seg=10, objective=PyGMO.problem._problem_space._gtoc_2_objective.MASS_TIME)¶
Constructs a GTOC 2 Problem (Constrained Continuous Single-Objective)
- NOTE: This problem is a quite faithful transcription of the problem used during the GTOC2 competition
- It Transcribe the whole OCP resulting from the low-thrust dynamics into an NLP. As such it is very
- difficult to find feasible solutions. Note that by default the asteroid sequence is the winning one from Turin University.
USAGE: problem.gtoc_2(ast1 = 815, ast2 = 300, ast3 = 110, ast4 = 47, n_seg = 10, objective = gtoc_2.obj.MASS_TIME)
- ast1 id of the first asteroid to visit (Group 1: 0 - 95)
- ast2 id of the second asteroid to visit (Group 2: 96 - 271)
- ast3 id of the third asteroid to visit (Group 3: 272 - 571)
- ast4 id of the fourth asteroid to visit (Group 4: 572 - 909)
- n_seg number of segments to be used per leg
- obj objective function in the enum {MASS,TIME,MASS_TIME}
- class PyGMO.problem.py_pl2pl¶
- py_pl2pl.__init__(mass=1000, Tmax=0.05, Isp=2500, Vinf_0=3, Vinf_f=1e-12, nseg=10, departure=None, target=None, optimise4mass=False)¶
Constructs a low-thrust transfer between a departure planet and a target planet (Constrained Continuous Single-Objective)
NOTE: An impulsive transcription is used to transform into an NLP the Optimal Control Problem
USAGE: problem.py_pl2pl(self,mass=1000,Tmax=0.05,Isp=2500,Vinf_0=3,Vinf_f=0,nseg=10,departure = PyKEP.planet_ss(‘earth’), target = PyKEP.planet_ss(‘mars’))
mass: spacecraft mass at departure [kg]
Tmax: maximum allowed thrust [N]
Isp: spacecarft engine specific impulse [Isp]
Vinf_0: allowed maximum starting velocity [km/s]
- Vinf_f: allowed maximum arrival velocity [km/s]
(if negative it is interpreted as a minimum arrival velocity)
nseg: number of segments used for the impulsive transcription
departure: departure planet (a PyKEP planet)
target: arrival planet (a PyKEP planet)
- class PyGMO.problem.sagas¶
- sagas.__init__()¶
Constructs a SAGAS Problem (Box-Constrained Continuous Single-Objective)
NOTE: This problem (MGA-1DSM) belongs to the GTOP database [http://www.esa.int/gsp/ACT/inf/op/globopt.htm]
USAGE: problem.sagas()