source: stable/2.8/Cbc/examples/minimum.cpp @ 1856

Last change on this file since 1856 was 1574, checked in by lou, 8 years ago

Change to EPL license notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1// $Id: minimum.cpp 1574 2011-01-05 01:13:55Z stefan $
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  assert(numMpsReadErrors==0);
19#else
20  fprintf(stderr, "Do not know where to find sample MPS files.\n");
21  exit(1);
22#endif
23
24  // Pass data and solver to CbcModel
25  CbcModel model(solver1);
26
27  // uncomment to reduce printout
28  //model.setLogLevel(1);
29  //model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry);
30  // Do complete search
31  model.branchAndBound();
32  /* Print solution.  CbcModel clones solver so we
33     need to get current copy */
34  int numberColumns = model.solver()->getNumCols();
35   
36  const double * solution = model.solver()->getColSolution();
37   
38  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
39    double value=solution[iColumn];
40    if (fabs(value)>1.0e-7&&model.solver()->isInteger(iColumn)) 
41      printf("%d has value %g\n",iColumn,value);
42  }
43  return 0;
44}   
Note: See TracBrowser for help on using the repository browser.