TRFInterface

(class from pyomo.contrib.trustregion.interface)

class pyomo.contrib.trustregion.interface.TRFInterface(model, decision_variables, ext_fcn_surrogate_map_rule, config)[source]

Bases: object

Pyomo interface for Trust Region algorithm.

__init__(model, decision_variables, ext_fcn_surrogate_map_rule, config)[source]

Methods

__init__(model, decision_variables, ...)

calculateFeasibility()

Feasibility measure (theta(x)) is:

calculateStepSizeInfNorm(original_values, ...)

Taking original and new values, calculate the step-size norm ||s_k||:

createConstraints()

Create the basis constraint y = b(w) (equation 3) and the surrogate model constraint y = r_k(w) (equation 5)

getCurrentDecisionVariableValues()

Return current decision variable values

getCurrentModelState()

Return current state of all model variables.

initializeProblem()

Initializes appropriate constraints, values, etc.

rejectStep()

If a step is rejected, we reset the model variables values back to their cached state - which we set in solveModel

replaceEF(expr)

Replace an External Function.

replaceExternalFunctionsWithVariables()

This method sets up essential data objects on the new trf_data block on the model as well as triggers the replacement of external functions in expressions trees.

solveModel()

Call the specified solver to solve the problem.

updateDecisionVariableBounds(radius)

Update the TRSP_k decision variable bounds

updateSurrogateModel()

The parameters needed for the surrogate model are the values of:

Member Documentation

calculateFeasibility()[source]
Feasibility measure (theta(x)) is:

|| y - d(w) ||_1

calculateStepSizeInfNorm(original_values, new_values)[source]
Taking original and new values, calculate the step-size norm ||s_k||:

|| u - u_k ||_inf

We assume that the user has correctly scaled their variables.

createConstraints()[source]

Create the basis constraint y = b(w) (equation 3) and the surrogate model constraint y = r_k(w) (equation 5)

Both constraints are immediately deactivated after creation and are activated later as necessary.

getCurrentDecisionVariableValues()[source]

Return current decision variable values

getCurrentModelState()[source]

Return current state of all model variables. This is necessary if we need to reject a step and move backwards.

initializeProblem()[source]

Initializes appropriate constraints, values, etc. for TRF problem

Returns:

  • objective_value (Initial objective)

  • feasibility (Initial feasibility measure)

STEPS:
  1. Create and solve PMP (eq. 3) and set equal to “x_0”

  2. Evaluate d(w_0)

  3. Evaluate initial feasibility measure (theta(x_0))

  4. Create initial SM (difference btw. low + high fidelity models)

rejectStep()[source]

If a step is rejected, we reset the model variables values back to their cached state - which we set in solveModel

replaceEF(expr)[source]

Replace an External Function.

Parameters:

expr – a Pyomo expression. We will search this expression tree

This function returns an expression after removing any ExternalFunction in the set efSet from the expression tree expr and replacing them with variables. New variables are declared on the TRF block.

TODO: Future work - investigate direct substitution of basis or surrogate models using Expression objects instead of new variables.

replaceExternalFunctionsWithVariables()[source]

This method sets up essential data objects on the new trf_data block on the model as well as triggers the replacement of external functions in expressions trees.

Data objects created:
self.data.all_variablesComponentSet

A set of all variables on the model, including “holder” variables from the EF replacement

self.data.truth_modelsComponentMap

A component map for replaced nodes that keeps track of the truth model for that replacement.

self.data.basis_expressionsComponentMap

A component map for the Pyomo expressions for basis functions as they apply to each variable

self.data.ef_inputsDict

A dictionary that tracks the input variables for each EF

self.data.ef_outputsVarList

A list of the “holder” variables which replaced the original External Function expressions

solveModel()[source]

Call the specified solver to solve the problem.

Returns:

  • self.data.objs[0] (Current objective value)

  • step_norm (Current step size inf norm)

  • feasibility (Current feasibility measure)

This also caches the previous values of the vars, just in case we need to access them later if a step is rejected

updateDecisionVariableBounds(radius)[source]

Update the TRSP_k decision variable bounds

This corresponds to:

\[|| E^{-1} (u - u_k) || <= trust_radius\]

We omit \(E^{-1}\) because we assume that the users have correctly scaled their variables.

updateSurrogateModel()[source]
The parameters needed for the surrogate model are the values of:

b(w_k) : basis_model_output d(w_k) : truth_model_output grad b(w_k) : grad_basis_model_output grad d(w_k) : grad_truth_model_output