13 #include <CoinPackedMatrix.hpp> 
   14 #include <OsiSolverInterface.hpp> 
   18 #include <CoinTime.hpp> 
   20 using namespace flopc;
 
   29     cout<<
"FlopCpp: Number of constraint blocks: " <<bm<<endl;
 
   30     cout<<
"FlopCpp: Number of individual constraints: " <<m<<endl;
 
   31     cout<<
"FlopCpp: Number of variable blocks: " <<bn<<endl;
 
   32     cout<<
"FlopCpp: Number of individual variables: " <<n<<endl;
 
   33     cout<<
"FlopCpp: Number of non-zeroes (including rhs): " <<nz<<endl;
 
   37     cout<<
"FlopCpp: Generation time: "<<t<<endl;
 
   41     cout<<
"FlopCpp: Constraint "<<name<<endl;
 
   42     for (
unsigned int j=0; j<cfs.size(); j++) {
 
   45         double elm=cfs[j].val;
 
   46         int stage=cfs[j].stage;
 
   47         cout<<row<<
"   "<<col<<
"  "<<elm<<
"  "<<stage<<endl;
 
   52     cout<<
"Objective "<<endl;
 
   53     for (
unsigned int j=0; j<cfs.size(); j++) {
 
   56         double elm=cfs[j].val;
 
   57         cout<<row<<
"   "<<col<<
"  "<<elm<<endl;
 
   62     solution(0), messenger(m), Objective(0), Solver(s), 
 
   63     m(0), n(0), nz(0), bl(0),
 
   83         return Solver->getInfinity();
 
   99     CoinPackedVector newRow;
 
  101     for (
unsigned int j=0; j<cfs.size(); j++) {
 
  104         double elm=cfs[j].val;
 
  107             newRow.insert(col,elm);
 
  108         } 
else if (col==-1) {
 
  114     double lcl_bl = -rhs;
 
  115     double lcl_bu = -rhs;
 
  117     double inf = 
Solver->getInfinity();
 
  118     switch (lcl_c.
sense) {
 
  130     Solver->addRow(newRow,lcl_bl,lcl_bu);
 
  141     lcl_c(s) = v() >= obj;
 
  148     bool operator() (
const Coef& a, 
const Coef& b)
 const {
 
  160     std::sort(v.begin(),v.end(),
CoefLess());
 
  163     std::vector<Coef>::const_iterator i = v.begin();
 
  170         while (i!=v.end() && c==i->col && r==i->row) {
 
  177         av.push_back(
Coef(c,r,val,s));
 
  186         cout<<
"no solver specified"<<endl;
 
  196         cout<<
"no solver specified"<<endl;
 
  205         cout<<
"no solver specified"<<endl;
 
  215         cout<<
"no solver specified"<<endl;
 
  231     double time = CoinCpuTime();
 
  237     typedef std::set<MP_variable* >::iterator 
varIt;
 
  238     typedef std::set<MP_constraint* >::iterator 
conIt;
 
  250     bool doAssemble = 
true;
 
  251     if (doAssemble == 
true) {
 
  254             (*i)->coefficients(f);
 
  257             cfs.erase(cfs.begin(),cfs.end());
 
  262             (*i)->coefficients(f);
 
  265     nz = 
static_cast<int>(coefs.size());
 
  269     Elm = 
new double[
nz]; 
 
  278     const double inf = 
Solver->getInfinity();
 
  280     for (
int j=0; j<
n; j++) {
 
  286     for (
int j=0; j<=
n; j++) {
 
  289     for (
int i=0; i<
nz; i++) {
 
  290         int col = coefs[i].col;
 
  297     for (
int j=0; j<=
n; j++) {
 
  300     for (
int i=0; i<=
n; i++) {
 
  303     for (
int i=0; i<
nz; i++) {
 
  304         int col = coefs[i].col;
 
  308         int row = coefs[i].row;
 
  309         double elm = coefs[i].val;
 
  311         Rnr[
Cst[col]+Clg[col]] = row;
 
  316     for (
int i=0; i<
m; i++) {
 
  320     for (
int j=
Cst[n]; j<
Cst[n+1]; j++) {
 
  322         bu[Rnr[j]] = -
Elm[j];
 
  326         int begin = (*i)->offset;
 
  327         int end = (*i)->offset+(*i)->size();
 
  328         switch ((*i)->sense) {
 
  330                 for (
int k=begin; k<end; k++) {
 
  335                 for (
int k=begin; k<end; k++) {
 
  347     if (doAssemble == 
true) {
 
  349         coefs.erase(coefs.begin(),coefs.end());
 
  356         coefs.erase(coefs.begin(),coefs.end());
 
  361     for (
int j=0; j<
n; j++) {
 
  364     for (
size_t i=0; i<coefs.size(); i++) {
 
  365         int col = coefs[i].col;
 
  366         double elm = coefs[i].val;
 
  371     for (
int j=0; j<
n; j++) {
 
  377         for (
int k=0; k<(*i)->size(); k++) {
 
  378             l[(*i)->offset+k] = (*i)->lowerLimit.v[k];
 
  379             u[(*i)->offset+k] = (*i)->upperLimit.v[k];
 
  383     CoinPackedMatrix A(
true,m,n,Cst[n],
Elm,
Rnr,Cst,
Clg);
 
  400         int begin = (*i)->offset;
 
  401         int end = (*i)->offset+(*i)->size();
 
  403             for (
int k=begin; k<end; k++) {
 
  435         } 
catch  (CoinError e) {
 
  436             cout<<e.message()<<endl;
 
  437             cout<<
"Solving the LP relaxation instead."<<endl;
 
  440             } 
catch (CoinError e) {
 
  441                 cout<<e.message()<<endl;
 
  447         }  
catch (CoinError e) {
 
  448             cout<<e.message()<<endl;
 
  452     if (
Solver->isProvenOptimal() == 
true) {
 
  453         cout<<
"FlopCpp: Optimal obj. value = "<<
Solver->getObjValue()<<endl;
 
  454         cout<<
"FlopCpp: Solver(m, n, nz) = "<<
Solver->getNumRows()<<
"  "<<
 
  455             Solver->getNumCols()<<
"  "<<
Solver->getNumElements()<<endl;
 
  460     } 
else if (
Solver->isProvenPrimalInfeasible() == 
true) {
 
  463     } 
else if (
Solver->isProvenDualInfeasible() == 
true) {
 
  481                 os<<
"PRIMAL_INFEASIBLE";
 
  484                 os<<
"DUAL_INFEASIBLE";
 
Symbolic representation of a linear expression.This is one of the main public interface classes...
 
MP_model(OsiSolverInterface *s, Messenger *m=new NormalMessenger)
Constructs an MP_model from an OsiSolverInterface *. 
 
std::ostream & operator<<(std::ostream &os, const MP_model::MP_status &condition)
allows print of result from call to solve(); 
 
static void assemble(std::vector< Coef > &v, std::vector< Coef > &av)
 
static MP_model * getCurrentModel()
 
double getInfinity() const 
 
std::set< MP_constraint * >::iterator conIt
 
MP_model & add(MP_constraint &c)
Adds a constrataint block to the model. 
 
std::set< MP_variable * >::iterator varIt
 
Inteface for hooking up to internal flopc++ message handling.In more advanced use of FlopC++...
 
virtual void statistics(int bm, int m, int bn, int n, int nz)
 
virtual void constraintDebug(std::string name, const std::vector< Coef > &cfs)
 
std::set< MP_variable * > Variables
 
virtual void generationTime(double t)
 
Functor to facilitate generation of the objective function. 
 
void setObjective(const MP_expression &o)
sets the "current objective" to the parameter o 
 
void addRow(const Constraint &c)
Adds a constraint to the MP_model. 
 
const double * rowActivity
 
static MP_model * current_model
 
A solver is attached, but not yet solved. 
 
MP_status
Reflects the state of the solution from solve() 
 
This is the anchor point for all constructs in a FlopC++ model.The constructors take an OsiSolverInte...
 
virtual void statistics(int bm, int m, int bn, int n, int nz)
 
OsiSolverInterface * Solver
 
if solve is called and solver finds model primal infeasible. 
 
MP_model::MP_status solve(const MP_model::MP_direction &dir)
 
Internal representation of a Coefficient in a matrix. 
 
static const MP_domain & getEmpty()
returns a reference to the "empty" set. 
 
void minimize_max(MP_set &d, const MP_expression &obj)
 
Symantic representation of a variable.This is one of the main public interface classes. It should be directly declared by clients of the FlopC++. The parametersof construction are MP_set s which specify the indexes over which the variable is defined. 
 
if solve is called and solver finds the model dual infeasible. 
 
Representation of a set for indexing into some other construct.This is one of the main public interfa...
 
const double * reducedCost
 
Functor to facilitate generation of coefficients. 
 
virtual void objectiveDebug(const std::vector< Coef > &cfs)
 
virtual void constraintDebug(std::string name, const std::vector< Coef > &cfs)
 
static MP_model & default_model
 
static MP_model & getDefaultModel()
 
if the solve method is called and the optimal solution found. 
 
MP_direction
used when calling the solve() method. 
 
virtual void objectiveDebug(const std::vector< Coef > &cfs)
 
void detach()
detaches an OsiSolverInterface object from the model. In essence, this will clean up any intermediate...
 
void attach(OsiSolverInterface *solver=NULL)
attaches the symantic representation of a model and data to a particular OsiSolverInterface ...
 
std::set< MP_constraint * > Constraints
 
virtual void generationTime(double t)
 
Semantic representation of a linear constraint.This is one of the main public interface classes...