Dynamic SC IP Interface
- class DynamicSchurComplementInteriorPointInterface(start_t: float, end_t: float, num_time_blocks: int)
Bases:
BaseInteriorPointInterface
A class for interfacing with Parapint’s interior point algorithm for the serial solution of dynamic optimization problems. This class is primarily for testing purposes. Users should favor the MPIDynamicSchurComplementInteriorPointInterface class because it supports parallel solution. To utilize this class, create a class which inherits from this class and implement the build_model_for_time_block method. If you override the __init__ method make sure to call the super class’ __init__ method at the end of the derived class’ __init__ method. See ex1.py in the examples directory for an example.
- Parameters
- start_t: float
The starting time for the dynamic optimization problem
- end_t: float
The final time for the dynamic optimization problem
- num_time_blocks: int
The number of time blocks to split the time horizon into for parallel solution. This is typically equal to the number of processes available (i.e., comm.Get_size()).
- abstract build_model_for_time_block(ndx: int, start_t: float, end_t: float, add_init_conditions: bool) Tuple[_BlockData, Sequence[_GeneralVarData], Sequence[_GeneralVarData]]
This method should be implemented by derived classes. This method should build (and return) the model for the time interval [start_t, end_t] and return a list of states at start_t and a list of states at end_t (in the same order). This method will be called once for each time block. The start_states and end_states returned by this method must be in the same order for every time block.
- Parameters
- ndx: int
The time block index
- start_t: float
- end_t: float
- add_init_conditions: bool
This will only be True for time block 0.
- Returns
- pyomo_model: pyomo.core.base.block.Block
The model for the time interval [start_t, end_t].
- start_states: Sequence of _GeneralVarData
a list of the states at start_t; the order of this list should be the same for every time block
- end_states: Sequence of _GeneralVarData
a list of the states at end_t; the order of this list should be the same for every time block
- n_primals() int
- Returns
- n_primals: int
The number of primal variables
- primals_lb() BlockVector
- Returns
- primals_lb: BlockVector
The lower bounds for each primal variable. This BlockVector has one block for every time block and one block for the coupling variables.
- primals_ub() BlockVector
- Returns
- primals_ub: BlockVector
The upper bounds for each primal variable. This BlockVector has one block for every time block and one block for the coupling variables.
- init_primals() BlockVector
- Returns
- init_primals: BlockVector
The initial values for each primal variable. This BlockVector has one block for every time block and one block for the coupling variables.
- set_primals(primals: BlockVector)
Set the values of the primal variables for evaluation (i.e., the evaluate_* methods).
- Parameters
- primals: BlockVector
The values for each primal variable. This BlockVector should have one block for every time block and one block for the coupling variables.
- get_primals() BlockVector
- Returns
- primals: BlockVector
The values for each primal variable. This BlockVector has one block for every time block and one block for the coupling variables.
- evaluate_objective() float
- Returns
- objective_val: float
The value of the objective
- evaluate_grad_objective() BlockVector
- Returns
- grad_obj: BlockVector
The gradient of the objective. This BlockVector has one block for every time block and one block for the coupling variables.
- n_eq_constraints() int
- Returns
- n_eq_constraints: int
The number of equality constraints, including the coupling constraints
- n_ineq_constraints() int
- Returns
- n_ineq_constraints: int
The number of inequality constraints
- ineq_lb() BlockVector
- Returns
- ineq_lb: BlockVector
The lower bounds for each inequality constraint. This BlockVector has one block for every time block.
- ineq_ub() BlockVector
- Returns
- ineq_lb: BlockVector
The lower bounds for each inequality constraint. This BlockVector has one block for every time block.
- init_duals_eq() BlockVector
- Returns
- init_duals_eq: BlockVector
The initial values for the duals of the equality constraints, including the coupling constraints. This BlockVector has one block for every time block. Each block is itself a BlockVector with 3 blocks. The first block contains the duals of the equality constraints in the corresponding time block. The second block has the duals for the coupling constraints linking the states at the beginning of the time block to the coupling variables between the time block and the previous time block. The third block has the duals for the coupling constraints linking the states at the end of the time block to the coupling variables between the time block and the next time block.
- init_duals_ineq() BlockVector
- Returns
- init_duals_ineq: BlockVector
The initial values for the duals of the inequality constraints. This BlockVector has one block for every time block.
- set_duals_eq(duals_eq: BlockVector)
- Parameters
- duals_eq: BlockVector
The values for the duals of the equality constraints, including the coupling constraints. This BlockVector has one block for every time block. Each block is itself a BlockVector with 3 blocks. The first block contains the duals of the equality constraints in the corresponding time block. The second block has the duals for the coupling constraints linking the states at the beginning of the time block to the coupling variables between the time block and the previous time block. The third block has the duals for the coupling constraints linking the states at the end of the time block to the coupling variables between the time block and the next time block.
- set_duals_ineq(duals_ineq: BlockVector)
- Parameters
- duals_ineq: BlockVector
The values for the duals of the inequality constraints. This BlockVector has one block for every time block.
- get_duals_eq() BlockVector
- Returns
- duals_eq: BlockVector
The values for the duals of the equality constraints, including the coupling constraints. This BlockVector has one block for every time block. Each block is itself a BlockVector with 3 blocks. The first block contains the duals of the equality constraints in the corresponding time block. The second block has the duals for the coupling constraints linking the states at the beginning of the time block to the coupling variables between the time block and the previous time block. The third block has the duals for the coupling constraints linking the states at the end of the time block to the coupling variables between the time block and the next time block.
- get_duals_ineq() BlockVector
- Returns
- duals_ineq: BlockVector
The values for the duals of the inequality constraints. This BlockVector has one block for every time block.
- evaluate_eq_constraints() BlockVector
- Returns
- eq_resid: BlockVector
The residuals of the equality constraints, including the coupling constraints. This BlockVector has one block for every time block. Each block is itself a BlockVector with 3 blocks. The first block contains the residuals of the equality constraints in the corresponding time block. The second block has the residuals for the coupling constraints linking the states at the beginning of the time block to the coupling variables between the time block and the previous time block. The third block has the residuals for the coupling constraints linking the states at the end of the time block to the coupling variables between the time block and the next time block.
- evaluate_ineq_constraints() BlockVector
- Returns
- ineq_resid: BlockVector
The residuals of the inequality constraints. This BlockVector has one block for every time block.
- evaluate_jacobian_eq() BlockMatrix
- Returns
- jac_eq: BlockMatrix
The jacobian of the equality constraints. The rows have the same structure as the BlockVector returned from evaluate_eq_constraints. The columns have the same structure as the BlockVector returned from get_primals.
- evaluate_jacobian_ineq() BlockMatrix
- Returns
- jac_ineq: BlockMatrix
The jacobian of the inequality constraints. The rows have the same structure as the BlockVector returned from evaluate_ineq_constraints. The columns have the same structure as the BlockVector returned from get_primals.
- load_primals_into_pyomo_model()
This method takes the current values for the primal variables (those you would get from the get_primals() method), and loads them into the corresponding Pyomo variables.
- pyomo_model(ndx: int) _BlockData
- Parameters
- ndx: int
The index of the time block for which the pyomo model should be returned.
- Returns
- m: _BlockData
The pyomo model for the time block corresponding to ndx.
- get_pyomo_variables(ndx: int) Sequence[_GeneralVarData]
- Parameters
- ndx: int
The index of the time block for which pyomo variables should be returned
- Returns
- pyomo_vars: list of _GeneralVarData
The pyomo variables in the model for the time block corresponding to ndx
- get_pyomo_constraints(ndx: int) Sequence[_GeneralConstraintData]
- Parameters
- ndx: int
The index of the time block for which pyomo constraints should be returned
- Returns
- pyomo_cons: list of _GeneralConstraintData
The pyomo constraints in the model for the time block corresponding to ndx
- get_primal_indices(ndx: int, pyomo_variables: Sequence[_GeneralVarData]) Sequence[int]
- Parameters
- ndx: int
The index of the time block
- pyomo_variables: Sequence of _GeneralVarData
The pyomo variables for which the indices should be returned
- Returns
- var_indices: Sequence of int
The indices of the corresponding pyomo variables. Note that these indices correspond to the specified time block, not the overall indices. In other words, the indices that are returned are the indices into the block within get_primals corresponding to ndx.
- get_constraint_indices(ndx, pyomo_constraints) Sequence[int]
- Parameters
- ndx: int
The index of the time block
- pyomo_constraints: Sequence of _GeneralConstraintData
The pyomo constraints for which the indices should be returned
- Returns
- con_indices: Sequence of int
The indices of the corresponding pyomo constraints. Note that these indices correspond to the specified time block, not the overall indices.