#include <NLPInterfacePack_NLPSerialPreprocess.hpp>
Inheritance diagram for NLPInterfacePack::NLPSerialPreprocess:
Overridden public members from NLP | |
| void | force_xinit_in_bounds (bool force_xinit_in_bounds) |
| | |
| bool | force_xinit_in_bounds () const |
| | |
| void | initialize (bool test_setup) |
| | |
| bool | is_initialized () const |
| | |
| size_type | n () const |
| | |
| size_type | m () const |
| | |
| vec_space_ptr_t | space_x () const |
| | |
| vec_space_ptr_t | space_c () const |
| | |
| size_type | num_bounded_x () const |
| | |
| const Vector & | xl () const |
| | |
| const Vector & | xu () const |
| | |
| const Vector & | xinit () const |
| | |
| void | get_init_lagrange_mult (VectorMutable *lambda, VectorMutable *nu) const |
| | |
| void | scale_f (value_type scale_f) |
| | |
| value_type | scale_f () const |
| | |
| void | report_final_solution (const Vector &x, const Vector *lambda, const Vector *nu, bool is_optimal) |
| Overridden to permute the variables back into an order that is natural to the subclass. | |
| virtual size_type | ns () const |
| | |
| vec_space_ptr_t | space_c_breve () const |
| | |
| vec_space_ptr_t | space_h_breve () const |
| | |
| const Vector & | hl_breve () const |
| | |
| const Vector & | hu_breve () const |
| | |
| const Permutation & | P_var () const |
| | |
| const Permutation & | P_equ () const |
| | |
Overridden public members from NLPVarReductPerm | |
| const perm_fcty_ptr_t | factory_P_var () const |
| | |
| const perm_fcty_ptr_t | factory_P_equ () const |
| | |
| Range1D | var_dep () const |
| | |
| Range1D | var_indep () const |
| | |
| Range1D | equ_decomp () const |
| | |
| Range1D | equ_undecomp () const |
| | |
| bool | nlp_selects_basis () const |
| | |
| bool | get_next_basis (Permutation *P_var, Range1D *var_dep, Permutation *P_equ, Range1D *equ_decomp) |
| | |
| void | set_basis (const Permutation &P_var, const Range1D &var_dep, const Permutation *P_equ, const Range1D *equ_decomp) |
| | |
| void | get_basis (Permutation *P_var, Range1D *var_dep, Permutation *P_equ, Range1D *equ_decomp) const |
| | |
Overridden protected members from NLP | |
| void | imp_calc_f (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const |
| | |
| void | imp_calc_c (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const |
| | |
| void | imp_calc_c_breve (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const |
| | |
| void | imp_calc_h_breve (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const |
| | |
Overridden protected members from NLPObjGrad | |
| void | imp_calc_Gf (const Vector &x, bool newx, const ObjGradInfo &obj_grad_info) const |
| | |
Pure virtual methods to be defined by subclasses | |
| virtual bool | imp_nlp_has_changed () const |
Return if the definition of the NLP has changed since the last call to initialize(). | |
| virtual size_type | imp_n_orig () const =0 |
| Return the number of variables in the original problem (including those fixed by bounds). | |
| virtual size_type | imp_m_orig () const =0 |
| Return the number of general equality constraints in the original problem. | |
| virtual size_type | imp_mI_orig () const =0 |
| Return the number of general inequality constraints in the original problem. | |
| virtual const DVectorSlice | imp_xinit_orig () const =0 |
Return the original initial point (size imp_n_orig()). | |
| virtual bool | imp_has_var_bounds () const =0 |
| Return if the NLP has bounds. | |
| virtual const DVectorSlice | imp_xl_orig () const =0 |
Return the original lower variable bounds (size imp_n_orig()). | |
| virtual const DVectorSlice | imp_xu_orig () const =0 |
Return the original upper variable bounds (size imp_n_orig()). | |
| virtual const DVectorSlice | imp_hl_orig () const =0 |
Return the original lower general inequality bounds (size imp_mI_orig()). | |
| virtual const DVectorSlice | imp_hu_orig () const =0 |
Return the original upper general inequality bounds (size imp_mI_orig()). | |
| virtual void | imp_calc_f_orig (const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const =0 |
| Calculate the objective function for the original NLP. | |
| virtual void | imp_calc_c_orig (const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const =0 |
| Calculate the vector for all of the general equality constaints in the original NLP. | |
| virtual void | imp_calc_h_orig (const DVectorSlice &x_full, bool newx, const ZeroOrderInfoSerial &zero_order_info) const =0 |
| Calculate the vector for all of the general inequality constaints in the original NLP. | |
| virtual void | imp_calc_Gf_orig (const DVectorSlice &x_full, bool newx, const ObjGradInfoSerial &obj_grad_info) const =0 |
| Calculate the vector for the gradient of the objective in the original NLP. | |
| virtual bool | imp_get_next_basis (IVector *var_perm_full, IVector *equ_perm_full, size_type *rank_full, size_type *rank) |
Return the next basis selection (default returns false). | |
| virtual void | imp_report_orig_final_solution (const DVectorSlice &x_full, const DVectorSlice *lambda_orig, const DVectorSlice *lambdaI_orig, const DVectorSlice *nu_orig, bool optimal) |
| To be overridden by subclasses to report the final solution in the original ordering natural to the subclass. | |
Other protected implementation functions for subclasses to call | |
| void | set_not_initialized () |
| Used by subclasses to set the state of the NLP to not initialized. | |
| void | assert_initialized () const |
| Assert if we have been initizlized (throws UnInitialized). | |
| void | set_x_full (const DVectorSlice &x, bool newx, DVectorSlice *x_full) const |
Set the full x vector if newx == true. | |
| DVectorSlice | x_full () const |
| Give reference to current x_full. | |
| const ZeroOrderInfoSerial | zero_order_orig_info () const |
| | |
| const ObjGradInfoSerial | obj_grad_orig_info () const |
| | |
| const IVector & | var_remove_fixed_to_full () const |
| Permutation vector for partitioning free and fixed variables. | |
| const IVector & | var_full_to_remove_fixed () const |
Inverse permutation vector of var_remove_fixed_to_full(). | |
| const IVector & | var_perm () const |
| Permutes from the compated variable vector (removing fixed variables) to the current basis selection. | |
| const IVector & | equ_perm () const |
| Permutes from the original constriant ordering to the current basis selection. | |
| const IVector & | inv_equ_perm () const |
Inverse of equ_perm(). | |
Public Member Functions | |
| NLPSerialPreprocess () | |
| Default Constructor. | |
Static Public Member Functions | |
| value_type | fixed_var_mult () |
| Gives the value of a Lagrange multipler for a fixed variable bound .that has been preprocessed out of the problem. | |
This is an implementation node class that takes an original NLP and transforms it by:
NLPVarReductPerm interface). Original NLP formulation
The original NLP (as specified by the subclass) takes the form:
min f_orig(x_orig)
s.t. c_orig(x_orig) = 0
hl_orig <= h(x_orig) <= hu_orig
xl_orig <= x_orig <= xu_orig
where:
x_orig <: REAL^n_orig
f_orig(x_orig) <: REAL^n_orig -> REAL
c_orig(x_orig) <: REAL^n_orig -> REAL^m_orig
h_orig(x_orig) <: REAL^n_orig -> REAL^mI_orig
Conversion of general inequalities to equalities using slack variables
The original NLP formulation above is transformed by adding slack variables s_orig <: REAL^mI_orig, defining a new x_full = [ x_orig; s_orig ] and forming the new NLP:
min f_full(x_full)
s.t. c_full(x_full) = 0
xl_full <= x_full <= xu_full
where:
x_full = [ x_orig ] n_orig
[ s_orig ] mI_orig
f_full(x_full) = f_orig(x_orig)
c_full(x_full) = [ c_orig(x_orig) ] m_orig
[ h_orig(x_orig) - s_orig ] mI_orig
xl_full = [ xl_orig ] n_orig
[ hl_orig ] mI_orig
xu_full = [ xu_orig ] n_orig
[ hu_orig ] mI_orig
Gc_full = [ Gc_orig Gh_orig ] n_orig
[ 0 -I ] mI_orig
m_orig mI_orig
Gf_full = [ Gf_orig ] n_orig
[ 0 ] mI_orig
imp_calc_Gc() and imp_calc_Gh() in a way that is consistent with the above transformation while also considering basis permutations (see NLPSerialPreprocessExplJac). As for the gradient Gc_full, the subclass can actually include terms for the slack variables in the objective function but the most common behavior will be to just ignore slack variables in the subclass.Preprocessing and basis manipulation
The initial basis selection is the original order (x_full = [ x_orig; s_orig ]) with the variables fixed by bounds being removed, and assumes there are no dependent equations (r == m).
The implementations of the Jacobian matrices Gc and Gh are not determined here and must be defined by an NLP subclass (see NLPSerialPreprocessExplJac for example).
This class stores the variable permutations and processing information in two parts. In the first state, the fixed variables are removed as:
var_remove_fixed_to_full = [ not fixed by bounds | fixed by bounds ]
[1 .. n|n+1 .. n_full]
The mapping i_full = var_remove_fixed_to_full()(i_free_fixed) gives the index of the original variable (i_full) for the sets of variables not fixed and fixed by bounds.
The inverse mapping i_free_fixed = var_full_to_remove_fixed()(i_full) can be used to determine if a variable is fixed by bounds or not..
On top of this partitioning of free and fixed variables, there is a second stage which is a permutation of the free variables into dependent and independent sets that is needed by the client.
var_perm = [ dependent variables | independent variables ]
[1.. n-r|n-r+1... n]
The mapping i_free_fixed = var_perm()(i_perm) is used to determine the index of a free variable in var_remove_fixed_to_full() given its index (i_perm) for the current basis selection.
For example, if x is the vector of variables for the current basis selection and x_full is the vector of variables in the original order including the fixed variables then the following is true:
x(i) == x_full(var_remove_fixed_to_full()(var_perm()(i))), for i = 1...n
The permutation equ_perm() gives the partitioning of the equality constraints into decomposed and undecomposed equalities. Decomposed inequality constraints are not supported currently.
Subclass developers notes
Handling of multiple updates by subclasses: Here we discuss the protocol for the handling of multiple updates to quantities during the calculation of other quantities. In order to simplify the implementation of subclasses as much as possible, storage for all iteration quantities will be passed to the subclass in the methods imp_calc_f_orig(), imp_calc_c_orig(), imp_calc_h_orig() and imp_calc_Gf_orig() regardless of what quantities where set by the user in the NLP interface. The subclass can always find out what was set by the client by calling get_f(), get_c(), get_Gf() etc. Therefore, in general, clients should just only compute what is required in each call to imp_calc_xxx_orig() and only update other quantities if it is absolutely free to do so (e.g. computing a function value when a gradient is computed using AD) or is required to do so (e.g.an external interface that forces both f_orig(x_orig), c_orig(x_orig) and h_orig(x_orig) be computed at the same time). It is up to the subclass to remember when a quantity has already been computed so that it will not be computed again unnecessarily. It is always safe for the subclass to ignore these issues and just do what is easiest. More careful implementations can be handled by the subclass by keeping track of get_xxx() and newx and remembering when quantities are computed.
The following methods from the NLP interface must be overridden by the NLP subclass: max_var_bounds_viol(), set_multi_calc(), multi_calc().
The following methods from the NLPVarReductPerm interface must be overridden by the NLP subclass: nlp_selects_basis().
In addition, the methods from this interface that must be overridden are: imp_n_orig(), imp_m_orig(), imp_mI_orig(), imp_xinit_orig(), imp_has_var_bounds(), imp_xl_orig(), imp_xu_orig(), imp_hl_orig(), imp_hu_orig(), imp_calc_f_orig(), imp_calc_c_orig(), imp_calc_h_orig() and imp_calc_Gf_orig().
The NLP method initialize() should also be overridden by all of the subclasses (and call initialize() on its direct subclass).
The following methods (with default implementations) may also be overridden by a subclass: imp_get_next_basis() and imp_report_orig_final_solution().
Definition at line 208 of file NLPInterfacePack_NLPSerialPreprocess.hpp.
|
|
Default Constructor.
This initalizes the basis to the first basis if the subclass specifies one and if not picks to first Definition at line 72 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Gives the value of a Lagrange multipler for a fixed variable bound .that has been preprocessed out of the problem.
Definition at line 65 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 83 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 88 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLPObjGrad. Reimplemented in NLPInterfacePack::NLPSerialPreprocessExplJac. Definition at line 93 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Reimplemented in NLPInterfacePack::NLPSerialPreprocessExplJac. Definition at line 320 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 325 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 331 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 337 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 343 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 349 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 354 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 360 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 366 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 372 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 385 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLP. Definition at line 391 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||||||
|
Overridden to permute the variables back into an order that is natural to the subclass.
The default implementation of this function is to call the method Reimplemented from NLPInterfacePack::NLP. Definition at line 397 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 443 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 450 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 457 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 464 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 470 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 476 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 482 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 491 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 497 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 502 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 508 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 514 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 520 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 526 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||||||
|
Implements NLPInterfacePack::NLPVarReductPerm. Reimplemented in NLPInterfacePack::NLPSerialPreprocessExplJac. Definition at line 544 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||||||
|
Implements NLPInterfacePack::NLPVarReductPerm. Reimplemented in NLPInterfacePack::NLPSerialPreprocessExplJac. Definition at line 561 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||||||
|
Implements NLPInterfacePack::NLPVarReductPerm. Definition at line 594 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Implements NLPInterfacePack::NLP. Definition at line 637 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Implements NLPInterfacePack::NLP. Definition at line 650 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 672 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Reimplemented from NLPInterfacePack::NLP. Definition at line 689 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Implements NLPInterfacePack::NLPObjGrad. Definition at line 707 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Return if the definition of the NLP has changed since the last call to
The default return is Definition at line 447 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Return the number of variables in the original problem (including those fixed by bounds).
|
|
|
Return the number of general equality constraints in the original problem.
|
|
|
Return the number of general inequality constraints in the original problem.
|
|
|
Return the original initial point (size
|
|
|
Return if the NLP has bounds.
|
|
|
Return the original lower variable bounds (size
Only to be called if <tt>-NLP::infinite_bound()</tt> |
|
|
Return the original upper variable bounds (size
Only to be called if <tt>+NLP::infinite_bound()</tt> |
|
|
Return the original lower general inequality bounds (size
Only to be called if
|
|
|
Return the original upper general inequality bounds (size
Only to be called if
|
|
||||||||||||||||
|
Calculate the objective function for the original NLP.
|
|
||||||||||||||||
|
Calculate the vector for all of the general equality constaints in the original NLP.
|
|
||||||||||||||||
|
Calculate the vector for all of the general inequality constaints in the original NLP.
|
|
||||||||||||||||
|
Calculate the vector for the gradient of the objective in the original NLP.
Note that the dimension of
On input, if |
|
||||||||||||||||||||
|
Return the next basis selection (default returns
This method will only be called if
The basis returned by the subclass must be sorted The first time this method is called, the subclass should return the first suggested basis selection (even if it happens to be identical to the original ordering).
The default implementation returns Definition at line 726 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||||||||||
|
To be overridden by subclasses to report the final solution in the original ordering natural to the subclass.
Note that the lagrange multipliers for fixed variables that have been preprocessed out of the problem are not computed by the optimization algorithm and are therefore not available. These multipliers are designated with the special value The default implementation of this function is to do nothing. Definition at line 610 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Used by subclasses to set the state of the NLP to not initialized.
Definition at line 832 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Assert if we have been initizlized (throws UnInitialized).
Reimplemented in NLPInterfacePack::NLPSerialPreprocessExplJac. Definition at line 736 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
||||||||||||||||
|
Set the full x vector if
Definition at line 743 of file NLPInterfacePack_NLPSerialPreprocess.cpp. |
|
|
Give reference to current x_full.
Definition at line 838 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Definition at line 845 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Definition at line 852 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Permutation vector for partitioning free and fixed variables.
var_remove_fixed_to_full = [ not fixed by bounds | fixed by bounds ]
[1 .. n|n + 1 .. n_full]
i_full = var_remove_fixed_to_full()(i_free_fixed) gives the index of the original variable (i_full) for the sets of variables not fixed and fixed (upper and lower bounds where equal).
Definition at line 858 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Inverse permutation vector of
The inverse mapping Definition at line 864 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Permutes from the compated variable vector (removing fixed variables) to the current basis selection. On top of this partitioning of free and fixed variables, there is a permutation of the free variables into dependent and independent variables that is needed by the optimization algorithm.
var_perm = [ dependent variables | independent variables ]
[1.. r|r+1.. n]
The mapping Definition at line 870 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Permutes from the original constriant ordering to the current basis selection.
equ_perm = [ decomposed equalities | undecomposed equalities ]
[1.. r|n-r+1... n]
The mapping Definition at line 876 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
|
|
Inverse of
The mapping Definition at line 882 of file NLPInterfacePack_NLPSerialPreprocess.hpp. |
1.3.9.1