Optimization Problem Types#

Classes for defining optimization problem objects.

Discrete Optimization Problem#

Class for defining discrete-state optimization problems.

class

class DiscreteOpt(length, fitness_fn, maximize=True, max_val=2)

Parameters:

  • length (int) – Number of elements in state vector.
  • fitness_fn (fitness function object) – Object to implement fitness function for optimization.
  • maximize (bool, default: True) – Whether to maximize the fitness function. Set False for minimization problem.
  • max_val (int, default: 2) – Number of unique values that each element in the state vector can take. Assumes values are integers in the range 0 to (max_val - 1), inclusive.

Continuous Optimization Problem#

Class for defining continuous-state optimization problems.

class

class ContinuousOpt(length, fitness_fn, maximize=True, min_val=0, max_val=1, step=0.1)

Parameters:

  • length (int) – Number of elements in state vector.
  • fitness_fn (fitness function object) – Object to implement fitness function for optimization.
  • maximize (bool, default: True) – Whether to maximize the fitness function. Set False for minimization problem.
  • min_val (float, default: 0) – Minimum value that each element of the state vector can take.
  • max_val (float, default: 1) – Maximum value that each element of the state vector can take.
  • step (float, default: 0.1) – Step size used in determining neighbors of current state.

Travelling Salesperson Optimization Problem#

Class for defining travelling salesperson optimization problems.

class

class TSPOpt(length, fitness_fn=None, maximize=False, coords=None, distances=None)

Parameters:

  • length (int) – Number of elements in state vector. Must equal number of nodes in the tour.
  • fitness_fn (fitness function object, default: None) – Object to implement fitness function for optimization. If None, then TravellingSales(coords=coords, distances=distances) is used by default.
  • maximize (bool, default: False) – Whether to maximize the fitness function. Set False for minimization problem.
  • coords (list of pairs, default: None) – Ordered list of the (x, y) co-ordinates of all nodes. This assumes that travel between all pairs of nodes is possible. If this is not the case, then use distances instead. This argument is ignored if fitness_fn is not None.
  • distances (list of triples, default: None) – List giving the distances, d, between all pairs of nodes, u and v, for which travel is possible, with each list item in the form (u, v, d). Order of the nodes does not matter, so (u, v, d) and (v, u, d) are considered to be the same. If a pair is missing from the list, it is assumed that travel between the two nodes is not possible. This argument is ignored if fitness_fn or coords is not None.