source: trunk/Cbc/examples/minimum.cpp

Last change on this file was 1898, checked in by stefan, 4 years ago

fixup examples

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