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

Last change on this file since 1854 was 1854, checked in by stefan, 6 years ago

fix svn keywords property

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1// $Id: barrier.cpp 1854 2013-01-28 00:02:55Z 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#if defined(_MSC_VER)
7// Turn off compiler warning about long names
8#  pragma warning(disable:4786)
9#endif
10
11#include <cassert>
12#include <iomanip>
13
14
15#include "OsiClpSolverInterface.hpp"
16#include  "CoinTime.hpp"
17
18//#############################################################################
19
20
21/************************************************************************
22
23This main program reads in a model from an mps file.
24
25It then tells the OsiClpSolver to use barrier for initialSolve
26
27The cryptic code was generated by playing around with "clp" and using -cpp
28option.
29
30So
31clp input.mps -cpp 1 -barrier
32
33created a user_driver.cpp from which the lines between ===== were taken
34
35************************************************************************/
36
37int main (int argc, const char *argv[])
38{
39
40  // Define your favorite OsiSolver
41 
42  OsiClpSolverInterface solver1;
43  // Taken from a user_driver.cpp
44  // =======================
45  ClpSolve::SolveType method = ClpSolve::useBarrier;
46  ClpSolve::PresolveType presolveType = ClpSolve::presolveOn;
47  int numberPasses = 5;
48#ifndef UFL_BARRIER
49  int options[] = {0,0,0,0,0,0};
50#else
51  // we can use UFL code
52  int options[] = {0,0,0,0,4,0};
53#endif
54  int extraInfo[] = {-1,-1,-1,-1,-1,-1};
55  int independentOptions[] = {0,0,3};
56  ClpSolve clpSolve(method,presolveType,numberPasses,
57                    options,extraInfo,independentOptions);
58  // =======================
59  // now pass options in
60  solver1.setSolveOptions(clpSolve);
61  // Read in model using argv[1]
62  // and assert that it is a clean model
63  std::string mpsFileName;
64#if defined(SAMPLEDIR)
65  mpsFileName = SAMPLEDIR "/p0033.mps";
66#else
67  if (argc < 2) {
68    fprintf(stderr, "Do not know where to find sample MPS files.\n");
69    exit(1);
70  }
71#endif
72  if (argc>=2) mpsFileName = argv[1];
73  int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),"");
74  assert(numMpsReadErrors==0);
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.