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

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

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

File size: 2.2 KB
RevLine 
[461]1// Copyright (C) 2006, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7
8#include <cassert>
9#include <iomanip>
10
11
12#include "OsiClpSolverInterface.hpp"
13#include  "CoinTime.hpp"
14
15//#############################################################################
16
17
18/************************************************************************
19
20This main program reads in a model from an mps file.
21
22It then tells the OsiClpSolver to use barrier for initialSolve
23
24The cryptic code was generated by playing around with "clp" and using -cpp
25option.
26
27So
28clp input.mps -cpp 1 -barrier
29
30created a user_driver.cpp from which the lines between ===== were taken
31
32************************************************************************/
33
34int main (int argc, const char *argv[])
35{
36
37  // Define your favorite OsiSolver
38 
39  OsiClpSolverInterface solver1;
40  // Taken from a user_driver.cpp
41  // =======================
42  ClpSolve::SolveType method = ClpSolve::useBarrier;
43  ClpSolve::PresolveType presolveType = ClpSolve::presolveOn;
44  int numberPasses = 5;
[462]45#ifndef UFL_BARRIER
[461]46  int options[] = {0,0,0,0,0,0};
[462]47#else
48  // we can use UFL code
49  int options[] = {0,0,0,0,4,0};
50#endif
[461]51  int extraInfo[] = {-1,-1,-1,-1,-1,-1};
52  int independentOptions[] = {0,0,3};
53  ClpSolve clpSolve(method,presolveType,numberPasses,
54                    options,extraInfo,independentOptions);
55  // =======================
56  // now pass options in
57  solver1.setSolveOptions(clpSolve);
58  // Read in model using argv[1]
59  // and assert that it is a clean model
[1464]60  std::string mpsFileName;
[1468]61#if defined(SAMPLEDIR)
[1464]62  mpsFileName = SAMPLEDIR "/p0033.mps";
63#else
64  if (argc < 2) {
65    fprintf(stderr, "Do not know where to find sample MPS files.\n");
66    exit(1);
67  }
68#endif
[461]69  if (argc>=2) mpsFileName = argv[1];
70  int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),"");
71  assert(numMpsReadErrors==0);
72  double time1 = CoinCpuTime();
73
74  solver1.initialSolve();
75
76  std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, "
77           <<" with objective "
78           <<solver1.getObjValue()
79           <<std::endl;
80
81  return 0;
82}   
Note: See TracBrowser for help on using the repository browser.