BlockIP
|
Class for perform conversions between standard form and original problem. More...
#include <StdForm.h>
Classes | |
struct | Transform |
Public Types | |
enum | TYPE_TRANSFORM { NON_ZERO_LB, _INF_LB, FREE_VAR, X_, SLACK, SURPLUS } |
Public Member Functions | |
StdForm () | |
Constructor. | |
~StdForm () | |
Destructor. | |
void | fobj_stdform (int n, double x[], double &fx, double Gx[], double Hx[], void *params) |
Function to calculate the objective function in a transformed variables point. | |
void | transformed_to_original_primal_variables (double *x) |
Converts a point from transformed variables to original variables space. | |
void | transformed_to_original_dual_variables (double *y, double *w, double *z) |
void | original_to_transformed_primal_variables (double *&xout, double *xin) |
Converts a point from original variables to transformed variables space. | |
void | transform_linear_and_quadratic_cost (double *&cost, double *&qcost, double &constant) |
Transforms objective function from original variables to transformed variables space. | |
void | original_to_transformed_names (string *&outVarNames, string *inVarNames, string *&outConsNames, string *inConsNames) |
Converts the variable names from original variables to transformed variables space. | |
void | delete_new_variables (double *&xout, double *xin) |
Public Attributes | |
int | numOrigVars |
Number of variables in the original problem. | |
int | numTransfVars |
Number of variables in the transformed (standardized) problem. | |
int | m_cons |
Number of constraints (including slacks) in the standardized problem. | |
int | numTransforms |
Number of transformations performed in variables. | |
int * | origVars |
Index to the original variables (that need a transformatiBon in objective function) in original problem, of size numTransforms. | |
int * | transfVars |
Index to the original variables (that need a transformation in objective function) in standardized problem, of size numTransforms. | |
Transform * | transforms |
Transformations performed in variables, of size numTransforms. | |
double | constantFObj |
Constant to add in the objective function. | |
vector< int > * | deletedRows |
Index to the rows that have been deleted. | |
double * | xOrig |
Optimal solution in the original problem. | |
double * | yOrig |
Optimal dual variables in the original problem. | |
double * | GxOrig |
Gradient in x in the original problem. | |
double * | HxOrig |
Hessian in x in the original problem. | |
double * | wOrig |
Optimal dual variables of x_i <= u_i bounds in the original problem. | |
double * | zOrig |
Optimal dual variables of x_i >= 0 bounds in the original problem. | |
void(* | fobj )(int n, double x[], double &fx, double Gx[], double Hx[], void *params) |
User function to calculate the objective function in a point. | |
Class for perform conversions between standard form and original problem.
StdForm::StdForm | ( | ) |
Constructor.
StdForm::~StdForm | ( | ) |
Destructor.
void StdForm::delete_new_variables | ( | double *& | xout, |
double * | xin | ||
) |
xout | Vector in original variables space, is allocated by the function with new, must be freed with delete[] |
xin | Vector in transformed variables space |
void StdForm::fobj_stdform | ( | int | n, |
double | x[], | ||
double & | fx, | ||
double | Gx[], | ||
double | Hx[], | ||
void * | params | ||
) |
Function to calculate the objective function in a transformed variables point.
Converts a point from transformed variables to original variables space and call the user function to calculate the objective function in that point, after that inverts the transformations to return the information in the transformed variables space
n | Number of variables in transformed variables space |
x | Point in transformed variables space |
fx | Objective function value in x |
Gx | Gradient in x |
Hx | Hessian in x |
params | User parameters to perform objective function calculations |
void StdForm::original_to_transformed_names | ( | string *& | outVarNames, |
string * | inVarNames, | ||
string *& | outConsNames, | ||
string * | inConsNames | ||
) |
Converts the variable names from original variables to transformed variables space.
outVarNames | Variable names including slacks, output in transformed variables space |
inVarNames | Variable names including slacks, input in original variables space |
outConsNames | Constraint names including linking constraints, output in transformed variables space |
inConsNames | Constraint names including linking constraints, input in original variables space |
void StdForm::original_to_transformed_primal_variables | ( | double *& | xout, |
double * | xin | ||
) |
Converts a point from original variables to transformed variables space.
xout | Point in transformed variables space, is allocated by the function with new, must be freed with delete[] |
xin | Point in original variables space |
void StdForm::transform_linear_and_quadratic_cost | ( | double *& | cost, |
double *& | qcost, | ||
double & | constant | ||
) |
Transforms objective function from original variables to transformed variables space.
cost | Linear cost of variables including slacks, input in original variables space, output in transformed variables space |
qcost | Quadratic cost of variables including slacks, input in original variables space, output in transformed variables space |
constant | Constant to add in the objective function |
void StdForm::transformed_to_original_dual_variables | ( | double * | y, |
double * | w, | ||
double * | z | ||
) |
Converts the dual variables y of constraints, and (z,w) of lower and upper bounds from transformed to original space.
Constraints of the form lhs <= Ax <= rhs are transformed to Ax+s= rhs, 0<= s<= rhs-lhs. y are the multipliers of Ax+s= rhs, and yOrig_l and yOrig_r the multipliers for, respectively, lhs <= Ax and Ax <=rhs. It can be seen that
Multipliers z are related to upper bounds x<=u, while multipliers w are related to lower bounds l<= x.
Variables without upper bounds do not have z; we will set the corresponding components zOrig(i)=0.
Free variables do not have z and w. We will set the corresponding components of zOrig(i)=wOrig(i)=0.
For variables with the transformation NON_ZERO_LB (x~= x-l) we have that zOrig(i)= z(i) and wOrig(i)= w(i).
For variables with the transformation _INF_LB (x~= -x+u) we have that zOrig(i)= w(i) and wOrig(i)= 0 =z(i).
y | Dual variables of constraint in standardized problem |
w | Dual variables of x_i <= u_i bounds in standardized problem |
z | Dual variables of x_i >= 0 bounds in standardized problem |
void StdForm::transformed_to_original_primal_variables | ( | double * | x | ) |
Converts a point from transformed variables to original variables space.
x | Point in transformed variables space |
double StdForm::constantFObj |
Constant to add in the objective function.
vector<int>* StdForm::deletedRows |
Index to the rows that have been deleted.
void(* StdForm::fobj)(int n, double x[], double &fx, double Gx[], double Hx[], void *params) |
User function to calculate the objective function in a point.
double* StdForm::GxOrig |
Gradient in x in the original problem.
double* StdForm::HxOrig |
Hessian in x in the original problem.
int StdForm::m_cons |
Number of constraints (including slacks) in the standardized problem.
int StdForm::numOrigVars |
Number of variables in the original problem.
int StdForm::numTransforms |
Number of transformations performed in variables.
int StdForm::numTransfVars |
Number of variables in the transformed (standardized) problem.
int* StdForm::origVars |
Index to the original variables (that need a transformatiBon in objective function) in original problem, of size numTransforms.
Transform* StdForm::transforms |
Transformations performed in variables, of size numTransforms.
int* StdForm::transfVars |
Index to the original variables (that need a transformation in objective function) in standardized problem, of size numTransforms.
double* StdForm::wOrig |
Optimal dual variables of x_i <= u_i bounds in the original problem.
double* StdForm::xOrig |
Optimal solution in the original problem.
double* StdForm::yOrig |
Optimal dual variables in the original problem.
double* StdForm::zOrig |
Optimal dual variables of x_i >= 0 bounds in the original problem.