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

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

merge split branch into trunk; fix some examples

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