FlopCpp trunk
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
flopc::MP_model Class Reference

This is the anchor point for all constructs in a FlopC++ model. More...

#include <MP_model.hpp>

+ Collaboration diagram for flopc::MP_model:

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 *.
 
 ~MP_model ()
 
MP_status getStatus () const
 Returns the current status of the model-solver interaction.
 
void silent ()
 used to silence FlopC++
 
void verbose ()
 used to help understanding and debugging FlopC++'s behavior.
 
void setSolver (OsiSolverInterface *s)
 allows for replacement of the solver used.
 
OsiSolverInterfaceoperator-> ()
 allows access to the OsiSolverInterface *
 
MP_modeladd (MP_constraint &c)
 Adds a constrataint block to the model.
 
void maximize ()
 Binds the data and calls the solver to maximize the current objective expression.
 
void maximize (const MP_expression &obj)
 Binds the data and calls the solver to maximize the parameter obj objective expression.
 
void minimize ()
 Binds the data and calls the solver to minimize the current objective expression.
 
void minimize (const MP_expression &obj)
 Binds the data and calls the solver to minimize the parameter obj objective expression.
 
void 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.
 
void setObjective (const MP_expression &o)
 sets the "current objective" to the parameter o
 
void attach (OsiSolverInterface *solver=NULL)
 attaches the symantic representation of a model and data to a particular OsiSolverInterface
 
void detach ()
 detaches an OsiSolverInterface object from the model.
 
MP_model::MP_status solve (const MP_model::MP_direction &dir)
 calls the appropriate solving methods in the OsiSolverInterface.
 
double getInfinity () const
 Useful for getting an appropriate value to pass in as "infinity".
 
void add (MP_variable *v)
 Adds a variable to the MP_model.
 
void addRow (const Constraint &c)
 Adds a constraint to the MP_model.
 
MessengergetMessenger ()
 Gets the current messenger.
 

Static Public Member Functions

static MP_modelgetDefaultModel ()
 Can be used to get the default model.
 
static MP_modelgetCurrentModel ()
 Can be used to get the current model.
 

Public Attributes

const double * solution
 Accessors for the results after a call to maximize()/minimize()
 
const double * reducedCost
 
const double * rowPrice
 
const double * rowActivity
 
OsiSolverInterfaceSolver
 

Friends

class MP_constraint
 

Detailed Description

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.

Member Enumeration Documentation

◆ MP_direction

used when calling the solve() method.

Enumerator
MINIMIZE 
MAXIMIZE 

Definition at line 93 of file MP_model.hpp.

◆ MP_status

Reflects the state of the solution from solve()

Enumerator
OPTIMAL 

if the solve method is called and the optimal solution found.

PRIMAL_INFEASIBLE 

if solve is called and solver finds model primal infeasible.

DUAL_INFEASIBLE 

if solve is called and solver finds the model dual infeasible.

ABANDONED 

if solve is called and solver abandons the problem (time?, iter limit?)

SOLVER_ONLY 

A solver is placed in the constructor, but it is not yet attached or solved.

ATTACHED 

A solver is attached, but not yet solved.

DETACHED 

No solver is attached.

Definition at line 97 of file MP_model.hpp.

Constructor & Destructor Documentation

◆ MP_model()

flopc::MP_model::MP_model ( OsiSolverInterface s,
Messenger m = new NormalMessenger 
)

Constructs an MP_model from an OsiSolverInterface *.

◆ ~MP_model()

flopc::MP_model::~MP_model ( )
inline

Definition at line 119 of file MP_model.hpp.

Member Function Documentation

◆ getStatus()

MP_status flopc::MP_model::getStatus ( ) const
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.

Note
It is not kept up to date if a call is made directly to the solver. Only if the MP_model interface is used.
See also
MP_status

Definition at line 130 of file MP_model.hpp.

◆ silent()

void flopc::MP_model::silent ( )
inline

used to silence FlopC++

Definition at line 134 of file MP_model.hpp.

◆ verbose()

void flopc::MP_model::verbose ( )
inline

used to help understanding and debugging FlopC++'s behavior.

Definition at line 139 of file MP_model.hpp.

◆ setSolver()

void flopc::MP_model::setSolver ( OsiSolverInterface s)
inline

allows for replacement of the solver used.

Definition at line 145 of file MP_model.hpp.

◆ operator->()

OsiSolverInterface * flopc::MP_model::operator-> ( )
inline

allows access to the OsiSolverInterface *

Definition at line 150 of file MP_model.hpp.

◆ add() [1/2]

MP_model & flopc::MP_model::add ( MP_constraint c)

Adds a constrataint block to the model.

◆ maximize() [1/2]

void flopc::MP_model::maximize ( )

Binds the data and calls the solver to maximize the current objective expression.

◆ maximize() [2/2]

void flopc::MP_model::maximize ( const MP_expression obj)

Binds the data and calls the solver to maximize the parameter obj objective expression.

◆ minimize() [1/2]

void flopc::MP_model::minimize ( )

Binds the data and calls the solver to minimize the current objective expression.

◆ minimize() [2/2]

void flopc::MP_model::minimize ( const MP_expression obj)

Binds the data and calls the solver to minimize the parameter obj objective expression.

◆ minimize_max()

void flopc::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.

◆ setObjective()

void flopc::MP_model::setObjective ( const MP_expression o)

sets the "current objective" to the parameter o

◆ attach()

void flopc::MP_model::attach ( OsiSolverInterface solver = NULL)

attaches the symantic representation of a model and data to a particular OsiSolverInterface

Note
this is called as a part of minimize(), maximize(), and minimize_max(); This takes the symantic representation of the model, generates coefficients for the matrices and adds them into the OsiSolverInterface. The OsiSolverInterface may be specified at construction time, or as late as the call to attach()

◆ detach()

void flopc::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.

Note
a solver may only be attached to one solver at a time
Todo:
verify that on "attach", old solver is detached.

◆ solve()

MP_model::MP_status flopc::MP_model::solve ( const MP_model::MP_direction dir)

calls the appropriate solving methods in the OsiSolverInterface.

Note
this is called as a part of minimize(), maximize(), and minimize_max() It expects that the object function is already set and only the direction is to be specified.
Todo:
should the direction be defaulted?

◆ getInfinity()

double flopc::MP_model::getInfinity ( ) const

Useful for getting an appropriate value to pass in as "infinity".

Note
some solvers may be more or less sensitive to the value.

◆ add() [2/2]

void flopc::MP_model::add ( MP_variable v)

Adds a variable to the MP_model.

◆ addRow()

void flopc::MP_model::addRow ( const Constraint c)

Adds a constraint to the MP_model.

◆ getDefaultModel()

static MP_model & flopc::MP_model::getDefaultModel ( )
static

Can be used to get the default model.

Todo:
explain the default and current model concepts.

◆ getCurrentModel()

static MP_model * flopc::MP_model::getCurrentModel ( )
static

Can be used to get the current model.

Todo:
explain the default and current model concepts.

◆ getMessenger()

Messenger * flopc::MP_model::getMessenger ( )
inline

Gets the current messenger.

Definition at line 235 of file MP_model.hpp.

Friends And Related Function Documentation

◆ MP_constraint

friend class MP_constraint
friend

Definition at line 90 of file MP_model.hpp.

Member Data Documentation

◆ solution

const double* flopc::MP_model::solution

Accessors for the results after a call to maximize()/minimize()

Todo:

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.

◆ reducedCost

const double* flopc::MP_model::reducedCost

Definition at line 212 of file MP_model.hpp.

◆ rowPrice

const double* flopc::MP_model::rowPrice

Definition at line 213 of file MP_model.hpp.

◆ rowActivity

const double* flopc::MP_model::rowActivity

Definition at line 214 of file MP_model.hpp.

◆ Solver

OsiSolverInterface* flopc::MP_model::Solver
Todo:
should this be private?

Definition at line 256 of file MP_model.hpp.


The documentation for this class was generated from the following file: