source: trunk/Cbc/examples/barrier.cpp

Last change on this file was 2469, checked in by unxusr, 6 weeks ago

formatting

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