FLOPC++
|
This is the anchor point for all constructs in a FlopC++ model.The constructors take an OsiSolverInterface, and (optionally) a replacemente for the Messenger class. There are some built-in changes to the verbosity for output.
The main methods to use are:
More...
#include <MP_model.hpp>
Public Types | |
enum | MP_direction { MINIMIZE =1, MAXIMIZE =-1 } |
used when calling the solve() method. More... | |
enum | MP_status { OPTIMAL, PRIMAL_INFEASIBLE, DUAL_INFEASIBLE, ABANDONED, SOLVER_ONLY, ATTACHED, DETACHED } |
Reflects the state of the solution from solve() More... | |
Public Member Functions | |
MP_model (OsiSolverInterface *s, Messenger *m=new NormalMessenger) | |
Constructs an MP_model from an OsiSolverInterface *. More... | |
~MP_model () | |
MP_status | getStatus () const |
Returns the current status of the model-solver interaction. This method will return the current understanding of the model in regard to the solver's state. More... | |
void | silent () |
used to silence FlopC++ More... | |
void | verbose () |
used to help understanding and debugging FlopC++'s behavior. More... | |
void | setSolver (OsiSolverInterface *s) |
allows for replacement of the solver used. More... | |
OsiSolverInterface * | operator-> () |
allows access to the OsiSolverInterface * More... | |
MP_model & | add (MP_constraint &c) |
Adds a constrataint block to the model. More... | |
void | maximize () |
void | maximize (const MP_expression &obj) |
void | minimize () |
void | minimize (const MP_expression &obj) |
void | minimize_max (MP_set &d, const MP_expression &obj) |
void | setObjective (const MP_expression &o) |
sets the "current objective" to the parameter o More... | |
void | attach (OsiSolverInterface *solver=NULL) |
attaches the symantic representation of a model and data to a particular OsiSolverInterface More... | |
void | detach () |
detaches an OsiSolverInterface object from the model. In essence, this will clean up any intermediate storage. A model may then be attached to another solverInterface. More... | |
MP_model::MP_status | solve (const MP_model::MP_direction &dir) |
double | getInfinity () const |
void | add (MP_variable *v) |
Adds a variable to the MP_model. More... | |
void | addRow (const Constraint &c) |
Adds a constraint to the MP_model. More... | |
Messenger * | getMessenger () |
Static Public Member Functions | |
static MP_model & | getDefaultModel () |
static MP_model * | getCurrentModel () |
Public Attributes | |
const double * | solution |
const double * | reducedCost |
const double * | rowPrice |
const double * | rowActivity |
OsiSolverInterface * | Solver |
Private Types | |
typedef std::set< MP_variable * > ::iterator | varIt |
typedef std::set < MP_constraint * >::iterator | conIt |
Private Member Functions | |
MP_model (const MP_model &) | |
MP_model & | operator= (const MP_model &) |
void | add (MP_constraint *c) |
Static Private Member Functions | |
static void | assemble (std::vector< Coef > &v, std::vector< Coef > &av) |
Private Attributes | |
Messenger * | messenger |
MP_expression | Objective |
std::set< MP_constraint * > | Constraints |
std::set< MP_variable * > | Variables |
int | m |
int | n |
int | nz |
int * | Cst |
int * | Clg |
int * | Rnr |
double * | Elm |
double * | bl |
double * | bu |
double * | c |
double * | l |
double * | u |
MP_status | mSolverState |
Static Private Attributes | |
static MP_model & | default_model = *new MP_model(0) |
static MP_model * | current_model = &MP_model::default_model |
Friends | |
class | MP_constraint |
This is the anchor point for all constructs in a FlopC++ model.
The constructors take an OsiSolverInterface, and (optionally) a replacemente for the Messenger class. There are some built-in changes to the verbosity for output.
The main methods to use are:
Definition at line 89 of file MP_model.hpp.
|
private |
Definition at line 240 of file MP_model.hpp.
|
private |
Definition at line 239 of file MP_model.hpp.
used when calling the solve() method.
Enumerator | |
---|---|
MINIMIZE | |
MAXIMIZE |
Definition at line 93 of file MP_model.hpp.
Reflects the state of the solution from solve()
Definition at line 97 of file MP_model.hpp.
MP_model::MP_model | ( | OsiSolverInterface * | s, |
Messenger * | m = new NormalMessenger |
||
) |
Constructs an MP_model from an OsiSolverInterface *.
Definition at line 61 of file MP_model.cpp.
References current_model.
|
inline |
Definition at line 119 of file MP_model.hpp.
References messenger.
|
private |
MP_model & MP_model::add | ( | MP_constraint & | c | ) |
Adds a constrataint block to the model.
Definition at line 68 of file MP_model.cpp.
References Constraints.
Referenced by attach(), minimize_max(), and flopc::MP_constraint::MP_constraint().
void MP_model::add | ( | MP_variable * | v | ) |
Adds a variable to the MP_model.
Definition at line 87 of file MP_model.cpp.
References flopc::MP_variable::M, n, flopc::MP_variable::offset, and flopc::RowMajor::size().
|
private |
Definition at line 73 of file MP_model.cpp.
References flopc::MP_constraint::M, m, flopc::MP_constraint::offset, and flopc::RowMajor::size().
void MP_model::addRow | ( | const Constraint & | c | ) |
Adds a constraint to the MP_model.
Definition at line 93 of file MP_model.cpp.
References flopc::EQ, flopc::GE, flopc::MP_domain::getEmpty(), flopc::LE, flopc::Constraint::left, flopc::Constraint::right, flopc::Constraint::sense, and Solver.
void MP_model::attach | ( | OsiSolverInterface * | solver = NULL | ) |
attaches the symantic representation of a model and data to a particular OsiSolverInterface
Definition at line 219 of file MP_model.cpp.
References add(), assemble(), ATTACHED, bl, bu, c, Clg, flopc::Messenger::constraintDebug(), Constraints, Cst, detach(), DETACHED, flopc::discrete, Elm, flopc::EQ, flopc::GE, flopc::Messenger::generationTime(), flopc::MP_domain::getEmpty(), l, flopc::LE, m, messenger, mSolverState, n, nz, Objective, flopc::Messenger::objectiveDebug(), Rnr, Solver, flopc::Messenger::statistics(), u, and Variables.
Referenced by maximize(), and minimize().
void MP_model::detach | ( | ) |
detaches an OsiSolverInterface object from the model. In essence, this will clean up any intermediate storage. A model may then be attached to another solverInterface.
Definition at line 412 of file MP_model.cpp.
References DETACHED, mSolverState, and Solver.
Referenced by attach().
|
static |
Can be used to get the current model
Definition at line 26 of file MP_model.cpp.
Referenced by flopc::MP_domain_base::display().
|
static |
Can be used to get the default model
Definition at line 25 of file MP_model.cpp.
Referenced by flopc::maximize(), flopc::minimize(), flopc::minimize_max(), and flopc::MP_variable::MP_variable().
double MP_model::getInfinity | ( | ) | const |
Useful for getting an appropriate value to pass in as "infinity"
Definition at line 79 of file MP_model.cpp.
References Solver.
|
inline |
Gets the current messenger.
Definition at line 235 of file MP_model.hpp.
References messenger.
Referenced by flopc::MP_domain_base::display().
|
inline |
Returns the current status of the model-solver interaction. This method will return the current understanding of the model in regard to the solver's state.
Definition at line 130 of file MP_model.hpp.
References mSolverState.
void MP_model::maximize | ( | ) |
Binds the data and calls the solver to maximize the current objective expression
Definition at line 181 of file MP_model.cpp.
References attach(), MAXIMIZE, solve(), and Solver.
Referenced by flopc::maximize().
void MP_model::maximize | ( | const MP_expression & | obj | ) |
void MP_model::minimize | ( | ) |
Binds the data and calls the solver to minimize the current objective expression
Definition at line 200 of file MP_model.cpp.
References attach(), MINIMIZE, solve(), and Solver.
Referenced by flopc::minimize(), and minimize_max().
void MP_model::minimize | ( | const MP_expression & | obj | ) |
void MP_model::minimize_max | ( | MP_set & | d, |
const MP_expression & | obj | ||
) |
Binds the data and calls the solver to minimize maximum value of the parameter obj objective expression
Definition at line 137 of file MP_model.cpp.
References add(), and minimize().
Referenced by flopc::minimize_max().
|
inline |
allows access to the OsiSolverInterface *
Definition at line 150 of file MP_model.hpp.
References Solver.
void MP_model::setObjective | ( | const MP_expression & | o | ) |
sets the "current objective" to the parameter o
Definition at line 133 of file MP_model.cpp.
References Objective.
|
inline |
allows for replacement of the solver used.
Definition at line 145 of file MP_model.hpp.
References Solver.
|
inline |
MP_model::MP_status MP_model::solve | ( | const MP_model::MP_direction & | dir | ) |
calls the appropriate solving methods in the OsiSolverInterface.
Definition at line 420 of file MP_model.cpp.
References ABANDONED, DETACHED, flopc::discrete, DUAL_INFEASIBLE, mSolverState, OPTIMAL, PRIMAL_INFEASIBLE, reducedCost, rowActivity, rowPrice, solution, Solver, SOLVER_ONLY, and Variables.
Referenced by maximize(), and minimize().
|
inline |
used to help understanding and debugging FlopC++'s behavior.
Definition at line 139 of file MP_model.hpp.
References messenger.
|
friend |
Definition at line 90 of file MP_model.hpp.
|
private |
Definition at line 265 of file MP_model.hpp.
Referenced by attach(), and flopc::MP_constraint::display().
|
private |
Definition at line 266 of file MP_model.hpp.
Referenced by attach(), and flopc::MP_constraint::display().
|
private |
Definition at line 267 of file MP_model.hpp.
Referenced by assemble(), and attach().
|
private |
Definition at line 262 of file MP_model.hpp.
Referenced by attach().
|
private |
Definition at line 252 of file MP_model.hpp.
|
private |
Definition at line 261 of file MP_model.hpp.
Referenced by attach().
|
staticprivate |
Definition at line 242 of file MP_model.hpp.
Referenced by flopc::MP_constraint::MP_constraint(), and MP_model().
Definition at line 241 of file MP_model.hpp.
|
private |
Definition at line 264 of file MP_model.hpp.
Referenced by attach().
|
private |
Definition at line 268 of file MP_model.hpp.
Referenced by attach().
|
private |
Definition at line 258 of file MP_model.hpp.
|
private |
Definition at line 246 of file MP_model.hpp.
Referenced by attach(), getMessenger(), silent(), verbose(), and ~MP_model().
|
private |
Definition at line 270 of file MP_model.hpp.
Referenced by attach(), detach(), getStatus(), and solve().
|
private |
Definition at line 259 of file MP_model.hpp.
|
private |
Definition at line 260 of file MP_model.hpp.
Referenced by attach().
|
private |
Definition at line 251 of file MP_model.hpp.
Referenced by attach(), maximize(), minimize(), and setObjective().
const double* flopc::MP_model::reducedCost |
Definition at line 212 of file MP_model.hpp.
Referenced by solve().
|
private |
Definition at line 263 of file MP_model.hpp.
Referenced by attach().
const double* flopc::MP_model::rowActivity |
Definition at line 214 of file MP_model.hpp.
Referenced by flopc::MP_constraint::display(), and solve().
const double* flopc::MP_model::rowPrice |
Definition at line 213 of file MP_model.hpp.
Referenced by flopc::MP_constraint::display(), and solve().
const double* flopc::MP_model::solution |
Accessors for the results after a call to maximize()/minimize()
should these be private with accessors? What if not set yet?
what if not a complete result? What if only one LP in the IP?
Definition at line 211 of file MP_model.hpp.
Referenced by flopc::VariableRef::level(), flopc::MP_variable::level(), flopc::MP_variable::operator()(), and solve().
OsiSolverInterface* flopc::MP_model::Solver |
Definition at line 256 of file MP_model.hpp.
Referenced by addRow(), attach(), detach(), getInfinity(), maximize(), minimize(), operator->(), setSolver(), and solve().
|
private |
Definition at line 269 of file MP_model.hpp.
Referenced by attach().
|
private |
Definition at line 253 of file MP_model.hpp.