Interfaces Reference

This page outlines the optimizer interfaces supported by Flume, which currently include SciPy and ParOpt.

class flume.interfaces.scipy_interface.FlumeScipyInterface(flume_sys: System, callback=None)
__init__(flume_sys: System, callback=None)

Creates an interface that is used to link an instance of a Flume System to SciPy’s optimize minimize function to perform numerical optimization.

Parameters:
  • flume_sys (System) – Instance of a Flume System that represents the problem to be solved with ParOpt

  • callback (callable function, default None) – This is a callable function that gets executed during every iteration of the evalObjCon method during optimization. See below for the structure of the function

  • update (callable function, default None) – This is a callable function that gets executed at the start of every iteration of the evalObjCon method during optimization. Nominally, this is used to do parameter updates, such as for a continuation strategy

get_default_options(method, maxit=100)

Get the dictionary of default options that are used when calling SciPy minimize.

Parameters:
  • method (str) – String that specifies the method used for the optimization

  • maxit (int) – Maximum number of iterations for the optimization problem

Returns:

options – Dictionary of default options for the optimization.

Return type:

dict

optimize_system(x0, options=None, method='SLSQP', maxit=100)

Function that the user calls to execute SciPy’s optimize minimize function.

Parameters:
  • x0 (np.ndarray) – Initial point for the optimization procedure

  • options (None or dict) – Default is None, otherwise this is a dictionary of options to provide to the minimize function

  • method (str) – String that specifies the method used for the optimization, defaults to SLSQP

  • maxit (int) – Maximum number of iterations for the optimization problem, defaults to 100

  • callback_func (callable function) – Optional callable function that the user can provide to override the default callback function, which calls Flume’s default log function after each iteration.

Returns:

  • res.x (np.ndarray) – Solution array after the optimization

  • res (SciPy OptimizeResult) – OptimizeResult instance from the numerical optimization (see SciPy documentation for additional details)

set_initial_point(initial_global_vars: dict)

Helper function that maps the design variables provided in the initial_global_vars dictionary to the array that SciPy expects for the initial point.

Parameters:

initial_global_vars (dict) – Dictionary, where each key-value pair corresponds to a global variable name in the Flume system and its corresponding numeric value. E.g. for a variable named ‘x’ with initial value 1 associated with an object named ‘rosenbrock’, the entry in this dictionary is ‘rosenbrock.x’: 1.0.

Returns:

x0 – NumPy array that contains the values provided in the initial_global_vars dictionary, organized according to the start/end indices for each variable.

Return type:

np.ndarray

class flume.interfaces.paropt_interface.FlumeParOptInterface(flume_sys: System, callback=None, update=None)
__init__(flume_sys: System, callback=None, update=None)

Creates an interface that is used to link an instance of a Flume System to a ParOpt optimization problem.

Parameters:
  • flume_sys (System) – Instance of a Flume System that represents the problem to be solved with ParOpt

  • callback (callable function, default None) – This is a callable function that gets executed during every iteration of the evalObjCon method during optimization. See below for the structure of the function

  • update (callable function, default None) – This is a callable function that gets executed at the start of every iteration of the evalObjCon method during optimization. Nominally, this is used to do parameter updates, such as for a continuation strategy

Note

The callback function is an arbitrary function that the user writes, and it will be called during every evalObjCon execution. It is required that the function is setup such that it takes in two arguments:

def user_callback(x, it_number):

Here, the parameters are: x : current design variable info for the problem it_number : current iteration number for the system

construct_paropt_problem()

Function that creates the ParOpt problem that will be used for optimization

Returns:

paroptprob – Returns an instance of the ParOptProb class

Return type:

ParOptProb

evalObjCon(x)

Evaluates the objective and constraints for the problem using the current design variables.

Parameters:

x (ParOptVec) – Design variable vector at the current iteration

Returns:

  • fail (int) – Returns 0 if the method evaluates successfully

  • obj (float) – Value of the objective function

  • con_list (list) – List of the constraint values at the current design point

evalObjConGradient(x, g, A)

Evaluates the objective and constraint gradients for the system.

Parameters:
  • x (ParOptVec) – Design variable vector at the current iteration

  • g (ParOptVec) – Gradient of the objective function at x

  • A (ParOptVec) – Gradients of the constraints evaluated at x

Returns:

fail – Returns 0 if the method evaluates successfully

Return type:

int

getVarsAndBounds(x, lb, ub)

Get the variable values and set the bounds for the optimization problem.

Parameters:
  • x (ParOptVec) – Design variable vector at the current iteration

  • lb (ParOptVec) – Vector containing the lower bounds to apply to the design variables in x

  • ub (ParOptVec) – Vector containing the ubber bounds to apply to the design variables in x

get_paropt_default_options(output_prefix, algorithm='tr', maxit=1000)

Get the default options for paropt.

Parameters:
  • output_prefix (str) – A string that specifies the directory where the output data should be stored

  • algorithm (str) – String that specifies the method to use, defaults to ‘tr’ which is trust-region

  • maxit (int) – Maximum number of iterations

Returns:

options – A dictionary containing the options that can be passed to ParOpt

Return type:

dict

set_system_variables(x, it_counter)

Sets the variable values for the analysis objects contained within the System.

Parameters:
  • x (ParOptVec) – Design variable vector at the current iteration

  • it_counter (int) – Current iteration for the optimization