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