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

Last change on this file since 461 was 461, checked in by forrest, 15 years ago

barrier example

File size: 1.9 KB
Line 
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;
45  int options[] = {0,0,0,0,0,0};
46  int extraInfo[] = {-1,-1,-1,-1,-1,-1};
47  int independentOptions[] = {0,0,3};
48  ClpSolve clpSolve(method,presolveType,numberPasses,
49                    options,extraInfo,independentOptions);
50  // =======================
51  // now pass options in
52  solver1.setSolveOptions(clpSolve);
53  // Read in model using argv[1]
54  // and assert that it is a clean model
55  std::string mpsFileName = "../../Data/Sample/p0033.mps";
56  if (argc>=2) mpsFileName = argv[1];
57  int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),"");
58  assert(numMpsReadErrors==0);
59  double time1 = CoinCpuTime();
60
61  solver1.initialSolve();
62
63  std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, "
64           <<" with objective "
65           <<solver1.getObjValue()
66           <<std::endl;
67
68  return 0;
69}   
Note: See TracBrowser for help on using the repository browser.