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

Last change on this file since 1432 was 333, checked in by andreasw, 13 years ago

finished examples subdir

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.1 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  int numMpsReadErrors = solver1.readMps("../../Data/Sample/p0033.mps","");
15  assert(numMpsReadErrors==0);
16
17  // Pass data and solver to CbcModel
18  CbcModel model(solver1);
19
20  // uncomment to reduce printout
21  //model.setLogLevel(1);
22  //model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
23  // Do complete search
24  model.branchAndBound();
25  /* Print solution.  CbcModel clones solver so we
26     need to get current copy */
27  int numberColumns = model.solver()->getNumCols();
28   
29  const double * solution = model.solver()->getColSolution();
30   
31  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
32    double value=solution[iColumn];
33    if (fabs(value)>1.0e-7&&model.solver()->isInteger(iColumn)) 
34      printf("%d has value %g\n",iColumn,value);
35  }
36  return 0;
37}   
Note: See TracBrowser for help on using the repository browser.