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

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

fixup examples

  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1// $Id: barrier.cpp 1898 2013-04-09 18:06:04Z stefan $
2// Copyright (C) 2006, 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 <cassert>
7#include <iomanip>
8
9
10#include "CoinPragma.hpp"
11#include "OsiClpSolverInterface.hpp"
12#include "CoinTime.hpp"
13
14//#############################################################################
15
16
17/************************************************************************
18
19This main program reads in a model from an mps file.
20
21It then tells the OsiClpSolver to use barrier for initialSolve
22
23The cryptic code was generated by playing around with "clp" and using -cpp
24option.
25
26So
27clp input.mps -cpp 1 -barrier
28
29created a user_driver.cpp from which the lines between ===== were taken
30
31************************************************************************/
32
33int main (int argc, const char *argv[])
34{
35
36  // Define your favorite OsiSolver
37 
38  OsiClpSolverInterface solver1;
39  // Taken from a user_driver.cpp
40  // =======================
41  ClpSolve::SolveType method = ClpSolve::useBarrier;
42  ClpSolve::PresolveType presolveType = ClpSolve::presolveOn;
43  int numberPasses = 5;
44#ifndef UFL_BARRIER
45  int options[] = {0,0,0,0,0,0};
46#else
47  // we can use UFL code
48  int options[] = {0,0,0,0,4,0};
49#endif
50  int extraInfo[] = {-1,-1,-1,-1,-1,-1};
51  int independentOptions[] = {0,0,3};
52  ClpSolve clpSolve(method,presolveType,numberPasses,
53                    options,extraInfo,independentOptions);
54  // =======================
55  // now pass options in
56  solver1.setSolveOptions(clpSolve);
57  // Read in model using argv[1]
58  // and assert that it is a clean model
59  std::string mpsFileName;
60#if defined(SAMPLEDIR)
61  mpsFileName = SAMPLEDIR "/p0033.mps";
62#else
63  if (argc < 2) {
64    fprintf(stderr, "Do not know where to find sample MPS files.\n");
65    exit(1);
66  }
67#endif
68  if (argc>=2) mpsFileName = argv[1];
69  int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),"");
70  if( numMpsReadErrors != 0 )
71  {
72     printf("%d errors reading MPS file\n", numMpsReadErrors);
73     return numMpsReadErrors;
74  }
75  double time1 = CoinCpuTime();
76
77  solver1.initialSolve();
78
79  std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, "
80           <<" with objective "
81           <<solver1.getObjValue()
82           <<std::endl;
83
84  return 0;
85}   
Note: See TracBrowser for help on using the repository browser.