source: trunk/Cbc/examples/minimum.cpp @ 1468

Last change on this file since 1468 was 1468, checked in by stefan, 9 years ago

do not require CbcConfig?.h in example to decide whether sample or miplib3 is present - do this in makefile

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1// Copyright (C) 2005, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4#include "CbcModel.hpp"
5
6// Using as solver
7#include "OsiClpSolverInterface.hpp"
8
9int main (int argc, const char *argv[])
10{
11  OsiClpSolverInterface solver1;
12  // Read in example model
13  // and assert that it is a clean model
14#if defined(SAMPLEDIR)
15  int numMpsReadErrors = solver1.readMps(SAMPLEDIR "/p0033.mps","");
16  assert(numMpsReadErrors==0);
17#else
18  fprintf(stderr, "Do not know where to find sample MPS files.\n");
19  exit(1);
20#endif
21
22  // Pass data and solver to CbcModel
23  CbcModel model(solver1);
24
25  // uncomment to reduce printout
26  //model.setLogLevel(1);
27  //model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
28  // Do complete search
29  model.branchAndBound();
30  /* Print solution.  CbcModel clones solver so we
31     need to get current copy */
32  int numberColumns = model.solver()->getNumCols();
33   
34  const double * solution = model.solver()->getColSolution();
35   
36  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
37    double value=solution[iColumn];
38    if (fabs(value)>1.0e-7&&model.solver()->isInteger(iColumn)) 
39      printf("%d has value %g\n",iColumn,value);
40  }
41  return 0;
42}   
Note: See TracBrowser for help on using the repository browser.