optimizer

The optimizer module provides wrappers which connect optimization packages to Evaluators. Currently we support platypus and rbf_opt

The supported Platypus algorithms are:

  • GeneticAlgorithm
  • EvolutionaryStrategy
  • NSGAII
  • EpsMOEA
  • GDE3
  • SPEA2
  • MOEAD
  • NSGAIII
  • ParticleSwarm
  • OMOPSO
  • SMPSO
  • CMAES
  • IBEA
  • PAES
  • PESA2
  • EpsNSGAII

These algorithms have the same configuration options as their counterparts in platypus, with the parts provided by besos evaluators filled automatically.

optimizer.df_solution_to_solutions(df: pandas.core.frame.DataFrame, platypus_problem: platypus.core.Problem, besos_problem: besos.problem.Problem) → List[platypus.core.Solution][source]

Converts a solution DataFrame to a list of platypus solutions, with each row converted to one solution

Parameters:
  • df – DataFrame to convert
  • platypus_problem – platypus problem that the solutions apply to
  • besos_problem – besos problem that the solutions apply to
Returns:

a list of platypus solutions

optimizer.df_to_solutions(df: pandas.core.frame.DataFrame, problem: platypus.core.Problem) → List[platypus.core.Solution][source]

Converts a DataFrame to a list of platypus solutions, with each row converted to one solution

Parameters:
  • df – DataFrame to convert
  • problem – platypus problem that the solutions apply to
Returns:

a list of platypus solutions

optimizer.get_operator(problem: platypus.core.Problem, mutation=False)[source]

Creates a valid operator for the given platypus Problem. This is provided to help when optimizing over problems with mixed types.

Parameters:
  • problem – the platypus problem this operator should apply to
  • mutation – if True create a mutation operator, if False create a variation operator
Returns:

optimizer.platypus_alg(evaluator: besos.evaluator.AbstractEvaluator, algorithm: Type[platypus.core.Algorithm], evaluations: int = 1000, *args, **kwargs) → pandas.core.frame.DataFrame[source]

Uses a platypus algorithm to optimise over an evaluator.

Parameters:
  • evaluator – An evaluation function to optimise over.
  • algorithm – The platypus algorithm to use.
  • evaluations – The algorithm will be stopped once it uses more than this many evaluations.
  • args – arguments to pass to algorithm
  • kwargs – keyword arguments to pass to algorithm.
Returns:

the non-dominated solutions found by the algorithm.

optimizer.rbf_opt(evaluator, evaluations, hide_output: bool = True, bonmin_path=None, rand_seed=None)[source]

This is wrapper to the rbfopt function.

Parameters:
  • evaluator – An evaluation function to optimise over.
  • evaluations – The algorithm will be stopped once it uses more than this many evaluations.
  • hide_output – Whether to suppress output from the rbf_opt algorithm
  • bonmin_path – The path to Bonmin, a specific feature useful for the cluster.
  • rand_seed – Give a seed number to make sure the random has numbers.
Returns:

a list of solutions

optimizer.solution_to_values(solution: platypus.core.Solution, parts='all') → list[source]

Converts a platypus solution to a list containing the same values

Parameters:
  • solution – a platypus solution to convert
  • parts – which parts of the solution should be kept
Returns:

a list of the requested values from the solution

optimizer.solutions_to_df(solutions: List[platypus.core.Solution], problem, parts='all', flag_optimal=True) → pandas.core.frame.DataFrame[source]

Converts a list of platypus solutions to a DataFrame, with one row corresponding to each solution

Parameters:
  • solutions – list of solutions to convert
  • problem – the column names for DataFrame
  • parts – which parts of the solutions should be kept
  • flag_optimal – whether to include a boolean column denoting whether each solution is pareto-optimal
Returns:

a DataFrame

optimizer.values_to_solution(values: list, problem: platypus.core.Problem, evaluate=True) → platypus.core.Solution[source]

Produces an unevaluated platypus solution with the given inputs

Parameters:
  • values – a list of input values to convert to a platypus solution
  • problem – the platypus problem this solution applies to
  • evaluate – whether to evaluate the solution before returning (solution will be unevaluated otherwise)
Returns:

the corresponding platypus.Solution object