Class for defining a mixed-integer nonlinear minimization problem. More...
#include <problem.h>
Public Types | |
enum | ptype { QQP, MINLP } |
Types of optimization problems. More... | |
Public Member Functions | |
MinlpProblem (ptype p_type=MINLP, char *prob_name_=(char *) NULL, Pointer< ostream > out_problem_p_=out_out_p, Pointer< ostream > out_problem_log_p_=out_log_p) | |
(Standard-)Constructor for an optimization problem. | |
MinlpProblem (Pointer< SepQcFunc > obj_, const dvector &lower_, const dvector &upper_, bool discr_=false, Pointer< ostream > out_problem_p_=out_out_p, Pointer< ostream > out_problem_log_p_=out_log_p) | |
Constructor for an objective function, the lower and upper bounds and a boolean, which indicates, whether all variables are discrete or continuous. | |
MinlpProblem (const MinlpProblem &p) | |
The copy constructor. | |
MinlpProblem (const MinlpProblem &p, int k) | |
Copy constructor for the variable structure of one block from another MinlpProblem. | |
virtual | ~MinlpProblem () |
Virtual Destructor. | |
int | dim () const |
Get's the dimension of the problem. | |
virtual void | add_var (int i_, int bnum, bool discr_, double lower_, double upper_, char *name=NULL) |
Add's a variable. | |
virtual void | add_con (Pointer< SepQcFunc > f, bool eq=true, char *name=NULL) |
Adds a constraint to the problem. | |
virtual void | del_con (int connr) |
Deletes one constraint from the problem. | |
virtual void | add_obj (Pointer< SepQcFunc > f) |
Add's (or replace) the objective function. | |
void | taylor_approx (UserVector< double > &point, const int degree=2) |
Does a second taylor approximation for this problem. | |
int | feasible (const UserVector< double > &x, double tol, ostream *out=NULL) |
Checks the point for feasibility according to the constraints, not the lower and upper bounds. | |
void | print_most_violated_constraints (const UserVector< double > &x, ostream &out, int nr=5, double tol=1E-4) |
Prints the names of those constraints that are most violated by a given point. | |
int | scale (Pointer< Param > param=NULL) |
Scales the constraints, using the primal_point. | |
int | scale (UserVector< double > &x, Pointer< Param > param=NULL) |
Scales the constraints. | |
void | get_sparsity (vector< Pointer< SparsityInfo > > &si) const |
Pointer< SparsityInfo > | get_sparsity (int k) const |
virtual void | print (ostream &out) const |
Prints some information about the problem. | |
void | print_as_gams (ostream &out) const |
Prints the problem in gams format. | |
Public Attributes | |
Pointer< ostream > | out_problem_p |
A Pointer to an ostream to print problem-relevant information to. | |
Pointer< ostream > | out_problem_log_p |
A Pointer to an ostream to print problem-relevant logging-information to. | |
ptype | problem_type |
The type of the problem. | |
Pointer< char > | prob_name |
A name for the problem. | |
vector< ivector > | block |
The block structure of the variables. | |
vector< Pointer< char > > | var_names |
The names of the variables. | |
Pointer< SepQcFunc > | obj |
The objective function. | |
vector< Pointer< SepQcFunc > > | con |
The constraints functions. | |
vector< Pointer< char > > | con_names |
The names of the constraints. | |
vector< bool > | con_eq |
Indicates, which constraints are equations and which are inequation. | |
vector< int > | i_discr |
The indices of the discrete variables. | |
vector< int > | i_cont |
The indices of the continuous variables. | |
vector< bool > | discr |
Indicates, whether variable is discrete (true) or continuous (false). | |
dvector | lower |
The lower bounds of the variables. | |
dvector | upper |
The upper bounds of the variables. | |
dvector | primal_point |
Used for fixing the discrete variables. | |
Protected Attributes | |
int | dim_ |
The dimension. | |
Private Member Functions | |
double | compute_scale (char *option, int c, double eps, UserVector< double > &x) |
Friends | |
ostream & | operator<< (ostream &out, const MinlpProblem &a) |
The output-operator. |
Class for defining a mixed-integer nonlinear minimization problem.
If i_discr is empty the problem is continuous.
constraint | scaling eps options $ 0$ default 0 The value $$ to which constraints are going to be scaled. Not applied currently. | |
constraint | scaling default options W*gradient | condition Jac | adjust by box ends | equalized default no scaling How to scale the constraints. | |
constraint | scaling max patterns options integer $ 0$ Maximum number of different patterns to scale specific type of constraints. | |
constraint | scaling pattern <$n$> options W*gradient | condition Jac | adjust by box ends | equalized | double $ 0$ How to scale the constraints that match the patters. Example: for all the constraints that contain the letter `E' {constraint scaling pattern 2 : E 1.} {constraint scaling pattern 2 : E number or equalized or condition Jac or none} |
Definition at line 35 of file problem.h.
enum MinlpProblem::ptype |
MinlpProblem::MinlpProblem | ( | ptype | p_type = MINLP , |
|
char * | prob_name_ = (char*)NULL , |
|||
Pointer< ostream > | out_problem_p_ = out_out_p , |
|||
Pointer< ostream > | out_problem_log_p_ = out_log_p | |||
) | [inline] |
(Standard-)Constructor for an optimization problem.
Variables, objective function and constraints should then be add with the appropriate methods.
p_type | The type of the optimization problem. By default, it's set to MINLP. | |
prob_name | A name for the problem. | |
out_problem_p_ | A Pointer to an ostream to print the problem-releated information to, default is out_out_p. | |
out_problem_log_p_ | A Pointer to an ostream to print the problem-related logging-information to, default is out_log_p. |
MinlpProblem::MinlpProblem | ( | Pointer< SepQcFunc > | obj_, | |
const dvector & | lower_, | |||
const dvector & | upper_, | |||
bool | discr_ = false , |
|||
Pointer< ostream > | out_problem_p_ = out_out_p , |
|||
Pointer< ostream > | out_problem_log_p_ = out_log_p | |||
) | [inline] |
Constructor for an objective function, the lower and upper bounds and a boolean, which indicates, whether all variables are discrete or continuous.
Set's the dimension of the problem to the dimension of the objective function.
obj_ | The objective function. | |
lower_ | The lower bounds of the variables. | |
upper_ | The upper bounds of the variables. | |
discr_ | If true, each variable is set to be discrete. If false, each variable is set to be continuous. Default is false. | |
out_problem_p_ | A pointer to an ostream to print the problem-releated information to, default is out_out_p. | |
out_problem_log_p_ | A pointer to an ostream to print the problem-related logging-information to, default is out_log_p. |
MinlpProblem::MinlpProblem | ( | const MinlpProblem & | p | ) | [inline] |
The copy constructor.
p | The MinlpProblem to copy. |
MinlpProblem::MinlpProblem | ( | const MinlpProblem & | p, | |
int | k | |||
) |
Copy constructor for the variable structure of one block from another MinlpProblem.
This does not copy the constraints.
p | The problem to take one block from. | |
k | The number of the block to take. |
virtual MinlpProblem::~MinlpProblem | ( | ) | [inline, virtual] |
double MinlpProblem::compute_scale | ( | char * | option, | |
int | c, | |||
double | eps, | |||
UserVector< double > & | x | |||
) | [private] |
int MinlpProblem::dim | ( | ) | const [inline] |
virtual void MinlpProblem::add_var | ( | int | i_, | |
int | bnum, | |||
bool | discr_, | |||
double | lower_, | |||
double | upper_, | |||
char * | name = NULL | |||
) | [virtual] |
Add's a variable.
Increases the dimension of the problem.
Add's the index i_ to block bnum.
If discr_ is true, adds the index to i_discr. If discr_ is false, adds the index to i_cont.
Add's discr_ to disrc.
Add's lower_ to lower. Add's upper_ to upper.
i_ | The index of the new variable. | |
bnum | The number of the block, where this variable belongs to. | |
discr_ | Indicates, whether variable is discrete (true) or not (false). | |
lower_ | The lower bound of this variable. | |
upper_ | The upper bound of this variable. | |
name | The name of the variable as pointer of char, default is NULL. |
virtual void MinlpProblem::add_con | ( | Pointer< SepQcFunc > | f, | |
bool | eq = true , |
|||
char * | name = NULL | |||
) | [virtual] |
Adds a constraint to the problem.
Adds f to con, init's the Ablock of f, copys the name and add eq to con_eq.
f | The function. | |
eq | Indicates, whether it's an equality-(true) or inequality-(false)-function. Default-Value is true. | |
name | The name of the constraint as pointer of char. Default is NULL. |
virtual void MinlpProblem::del_con | ( | int | connr | ) | [virtual] |
Deletes one constraint from the problem.
connr | The number of the constraint to delete. |
Add's (or replace) the objective function.
f | The objective function, which should be used. |
void MinlpProblem::taylor_approx | ( | UserVector< double > & | point, | |
const int | degree = 2 | |||
) |
Does a second taylor approximation for this problem.
Changes the type of this problem to QQP.
point | The point, where the approximation should be done. |
int MinlpProblem::feasible | ( | const UserVector< double > & | x, | |
double | tol, | |||
ostream * | out = NULL | |||
) |
Checks the point for feasibility according to the constraints, not the lower and upper bounds.
x | The UserVector<double> to check. | |
tol | The tolerance, default is rtol. |
void MinlpProblem::print_most_violated_constraints | ( | const UserVector< double > & | x, | |
ostream & | out, | |||
int | nr = 5 , |
|||
double | tol = 1E-4 | |||
) |
Prints the names of those constraints that are most violated by a given point.
Each constraint is scaled by max(1,||gradient of constraint at x||_2).
x | The point to check | |
out | Where to print to. | |
nr | How many violated constraints to print. | |
tol | A feasibility tolerance. |
int MinlpProblem::scale | ( | UserVector< double > & | x, | |
Pointer< Param > | param = NULL | |||
) |
Scales the constraints.
param | Optional parameters, default is NULL. | |
x | The UserVector<double> to compute for. |
void MinlpProblem::get_sparsity | ( | vector< Pointer< SparsityInfo > > & | si | ) | const |
Pointer<SparsityInfo> MinlpProblem::get_sparsity | ( | int | k | ) | const |
virtual void MinlpProblem::print | ( | ostream & | out | ) | const [virtual] |
Prints some information about the problem.
Prints out:
out | The ostream to print to. |
void MinlpProblem::print_as_gams | ( | ostream & | out | ) | const |
Prints the problem in gams format.
Working only for MIQQPs!
ostream& operator<< | ( | ostream & | out, | |
const MinlpProblem & | a | |||
) | [friend] |
The output-operator.
Calls print(out).
out | The ostream to print to. | |
a | The MinlpProblem to print. |
int MinlpProblem::dim_ [protected] |
Pointer<ostream> MinlpProblem::out_problem_p |
A Pointer to an ostream to print problem-relevant information to.
Pointer<ostream> MinlpProblem::out_problem_log_p |
A Pointer to an ostream to print problem-relevant logging-information to.
vector<ivector> MinlpProblem::block |
The block structure of the variables.
vector<Pointer<char> > MinlpProblem::var_names |
The names of the variables.
vector<Pointer<SepQcFunc> > MinlpProblem::con |
vector<Pointer<char> > MinlpProblem::con_names |
vector<bool> MinlpProblem::con_eq |
vector<int> MinlpProblem::i_discr |
The indices of the discrete variables.
vector<int> MinlpProblem::i_cont |
The indices of the continuous variables.
vector<bool> MinlpProblem::discr |
Indicates, whether variable is discrete (true) or continuous (false).
The lower bounds of the variables.
The upper bounds of the variables.