FLOPC++
Public Member Functions | Public Attributes | Private Attributes | List of all members
flopc::MP_constraint Class Reference

Semantic representation of a linear constraint.This is one of the main public interface classes. It is always constructed through operator overloading between expressions, constants, and variables. There are many 'friend' overloaded operators to do the constuction. The basic idea is to make the constraint look like a paper-model constraint in C++ code. Once constructed, it should be added to the model. More...

#include <MP_constraint.hpp>

Inheritance diagram for flopc::MP_constraint:
flopc::RowMajor flopc::Named

Public Member Functions

 MP_constraint (const MP_set_base &s1=MP_set::getEmpty(), const MP_set_base &s2=MP_set::getEmpty(), const MP_set_base &s3=MP_set::getEmpty(), const MP_set_base &s4=MP_set::getEmpty(), const MP_set_base &s5=MP_set::getEmpty())
 construct the MP_constraint with appropriate sets for indexing.
MP_constraintoperator() (const MP_index_exp &i1=MP_index_exp::getEmpty(), const MP_index_exp &i2=MP_index_exp::getEmpty(), const MP_index_exp &i3=MP_index_exp::getEmpty(), const MP_index_exp &i4=MP_index_exp::getEmpty(), const MP_index_exp &i5=MP_index_exp::getEmpty())
 operator int ()
virtual ~MP_constraint ()
double price (int i1=0, int i2=0, int i3=0, int i4=0, int i5=0) const
void coefficients (vector< MP::Coef > &cfs)
int row_number () const
MP_constraintsuch_that (const MP_boolean &b)
void insertVariables (set< MP_variable * > &v)
void operator= (const Constraint &v)
void display (string s="") const
- Public Member Functions inherited from flopc::RowMajor
int size () const
- Public Member Functions inherited from flopc::Named
string getName () const
void setName (const string &n)

Public Attributes

MP_modelM
int offset
MP_expression left
MP_expression right
Sense_enum sense

Private Attributes

MP_boolean B
const MP_set_baseS1
const MP_set_baseS2
const MP_set_baseS3
const MP_set_baseS4
const MP_set_baseS5
MP_index_exp I1
MP_index_exp I2
MP_index_exp I3
MP_index_exp I4
MP_index_exp I5

Additional Inherited Members

- Protected Member Functions inherited from flopc::RowMajor
 RowMajor (int s1, int s2, int s3, int s4, int s5)
int f (int i1=0, int i2=0, int i3=0, int i4=0, int i5=0) const
- Protected Attributes inherited from flopc::RowMajor
int size1
int size2
int size3
int size4
int size5
int size_

Detailed Description

Semantic representation of a linear constraint.

This is one of the main public interface classes. It is always constructed through operator overloading between expressions, constants, and variables. There are many 'friend' overloaded operators to do the constuction. The basic idea is to make the constraint look like a paper-model constraint in C++ code. Once constructed, it should be added to the model.

The snippet below is an overly simplistic example, but is ok for illustration.
MP_model aModel; // your model
MP_set I; // the set the constraint is defined over.
MP_variable x(I); // your variable
...
MP_constraint cons(I); // construct the right number of constraints.
cons = x <= 3;
// Assign in the semantic rep to it. aModel.add(cons); // add it to the model

There is quite a bit of C++ machinery going on there.

Definition at line 207 of file MP_constraint.hpp.

Constructor & Destructor Documentation

MP_constraint::MP_constraint ( const MP_set_base s1 = MP_set::getEmpty(),
const MP_set_base s2 = MP_set::getEmpty(),
const MP_set_base s3 = MP_set::getEmpty(),
const MP_set_base s4 = MP_set::getEmpty(),
const MP_set_base s5 = MP_set::getEmpty() 
)

construct the MP_constraint with appropriate sets for indexing.

Definition at line 50 of file MP_constraint.cpp.

References flopc::MP_model::add(), and flopc::MP_model::current_model.

virtual flopc::MP_constraint::~MP_constraint ( )
inlinevirtual

Definition at line 234 of file MP_constraint.hpp.

Member Function Documentation

void MP_constraint::coefficients ( vector< MP::Coef > &  cfs)

Definition at line 65 of file MP_constraint.cpp.

References B, flopc::RowMajor::f(), I1, I2, I3, I4, I5, flopc::Handle< T >::isDefined(), left, right, S1, S2, S3, S4, S5, and such_that().

void MP_constraint::display ( string  s = "") const

Definition at line 87 of file MP_constraint.cpp.

References M, offset, flopc::RowMajor::size(), and flopc::MP_model::Solver.

void MP_constraint::insertVariables ( set< MP_variable * > &  v)

Definition at line 78 of file MP_constraint.cpp.

References left, and right.

flopc::MP_constraint::operator int ( )
inline

Definition at line 229 of file MP_constraint.hpp.

References flopc::RowMajor::f(), I1, I2, I3, I4, I5, and offset.

MP_constraint& flopc::MP_constraint::operator() ( const MP_index_exp i1 = MP_index_exp::getEmpty(),
const MP_index_exp i2 = MP_index_exp::getEmpty(),
const MP_index_exp i3 = MP_index_exp::getEmpty(),
const MP_index_exp i4 = MP_index_exp::getEmpty(),
const MP_index_exp i5 = MP_index_exp::getEmpty() 
)
inline

Definition at line 218 of file MP_constraint.hpp.

References I1, I2, I3, I4, and I5.

void MP_constraint::operator= ( const Constraint v)

Definition at line 24 of file MP_constraint.cpp.

References left, right, and sense.

double MP_constraint::price ( int  i1 = 0,
int  i2 = 0,
int  i3 = 0,
int  i4 = 0,
int  i5 = 0 
) const

Definition at line 46 of file MP_constraint.cpp.

References flopc::RowMajor::f(), M, offset, and flopc::MP_model::Solver.

int MP_constraint::row_number ( ) const

Definition at line 30 of file MP_constraint.cpp.

References flopc::MP_set_base::check(), flopc::RowMajor::f(), I1, I2, I3, I4, I5, offset, flopc::outOfBound, S1, S2, S3, S4, and S5.

MP_constraint& flopc::MP_constraint::such_that ( const MP_boolean b)
inline

Definition at line 242 of file MP_constraint.hpp.

References B.

Referenced by coefficients().

Member Data Documentation

MP_boolean flopc::MP_constraint::B
private

Definition at line 258 of file MP_constraint.hpp.

Referenced by coefficients(), and such_that().

MP_index_exp flopc::MP_constraint::I1
private

Definition at line 260 of file MP_constraint.hpp.

Referenced by coefficients(), operator int(), operator()(), and row_number().

MP_index_exp flopc::MP_constraint::I2
private

Definition at line 260 of file MP_constraint.hpp.

Referenced by coefficients(), operator int(), operator()(), and row_number().

MP_index_exp flopc::MP_constraint::I3
private

Definition at line 260 of file MP_constraint.hpp.

Referenced by coefficients(), operator int(), operator()(), and row_number().

MP_index_exp flopc::MP_constraint::I4
private

Definition at line 260 of file MP_constraint.hpp.

Referenced by coefficients(), operator int(), operator()(), and row_number().

MP_index_exp flopc::MP_constraint::I5
private

Definition at line 260 of file MP_constraint.hpp.

Referenced by coefficients(), operator int(), operator()(), and row_number().

MP_expression flopc::MP_constraint::left

Definition at line 255 of file MP_constraint.hpp.

Referenced by flopc::MP_model::add(), coefficients(), insertVariables(), and operator=().

MP_model* flopc::MP_constraint::M

Definition at line 253 of file MP_constraint.hpp.

Referenced by flopc::MP_model::add(), display(), and price().

int flopc::MP_constraint::offset

Definition at line 254 of file MP_constraint.hpp.

Referenced by flopc::MP_model::add(), display(), operator int(), price(), and row_number().

MP_expression flopc::MP_constraint::right

Definition at line 255 of file MP_constraint.hpp.

Referenced by flopc::MP_model::add(), coefficients(), insertVariables(), and operator=().

const MP_set_base& flopc::MP_constraint::S1
private

Definition at line 259 of file MP_constraint.hpp.

Referenced by coefficients(), and row_number().

const MP_set_base & flopc::MP_constraint::S2
private

Definition at line 259 of file MP_constraint.hpp.

Referenced by coefficients(), and row_number().

const MP_set_base & flopc::MP_constraint::S3
private

Definition at line 259 of file MP_constraint.hpp.

Referenced by coefficients(), and row_number().

const MP_set_base & flopc::MP_constraint::S4
private

Definition at line 259 of file MP_constraint.hpp.

Referenced by coefficients(), and row_number().

const MP_set_base & flopc::MP_constraint::S5
private

Definition at line 259 of file MP_constraint.hpp.

Referenced by coefficients(), and row_number().

Sense_enum flopc::MP_constraint::sense

Definition at line 256 of file MP_constraint.hpp.

Referenced by operator=().


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