TRFInterface
(class from pyomo.contrib.trustregion.interface)
- class pyomo.contrib.trustregion.interface.TRFInterface(model, decision_variables, ext_fcn_surrogate_map_rule, config)[source]
Bases:
objectPyomo interface for Trust Region algorithm.
Methods
__init__(model, decision_variables, ...)Feasibility measure (theta(x)) is:
calculateStepSizeInfNorm(original_values, ...)Taking original and new values, calculate the step-size norm ||s_k||:
Create the basis constraint y = b(w) (equation 3) and the surrogate model constraint y = r_k(w) (equation 5)
Return current decision variable values
Return current state of all model variables.
Initializes appropriate constraints, values, etc.
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.
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.
Call the specified solver to solve the problem.
updateDecisionVariableBounds(radius)Update the TRSP_k decision variable bounds
The parameters needed for the surrogate model are the values of:
Member Documentation
- 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.
- 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:
Create and solve PMP (eq. 3) and set equal to “x_0”
Evaluate d(w_0)
Evaluate initial feasibility measure (theta(x_0))
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