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 | |
---|
20 | This main program reads in a model from an mps file. |
---|
21 | |
---|
22 | It then tells the OsiClpSolver to use barrier for initialSolve |
---|
23 | |
---|
24 | The cryptic code was generated by playing around with "clp" and using -cpp |
---|
25 | option. |
---|
26 | |
---|
27 | So |
---|
28 | clp input.mps -cpp 1 -barrier |
---|
29 | |
---|
30 | created a user_driver.cpp from which the lines between ===== were taken |
---|
31 | |
---|
32 | ************************************************************************/ |
---|
33 | |
---|
34 | int 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 | #ifndef UFL_BARRIER |
---|
46 | int options[] = {0,0,0,0,0,0}; |
---|
47 | #else |
---|
48 | // we can use UFL code |
---|
49 | int options[] = {0,0,0,0,4,0}; |
---|
50 | #endif |
---|
51 | int extraInfo[] = {-1,-1,-1,-1,-1,-1}; |
---|
52 | int independentOptions[] = {0,0,3}; |
---|
53 | ClpSolve clpSolve(method,presolveType,numberPasses, |
---|
54 | options,extraInfo,independentOptions); |
---|
55 | // ======================= |
---|
56 | // now pass options in |
---|
57 | solver1.setSolveOptions(clpSolve); |
---|
58 | // Read in model using argv[1] |
---|
59 | // and assert that it is a clean model |
---|
60 | std::string mpsFileName; |
---|
61 | #if defined(SAMPLEDIR) |
---|
62 | mpsFileName = SAMPLEDIR "/p0033.mps"; |
---|
63 | #else |
---|
64 | if (argc < 2) { |
---|
65 | fprintf(stderr, "Do not know where to find sample MPS files.\n"); |
---|
66 | exit(1); |
---|
67 | } |
---|
68 | #endif |
---|
69 | if (argc>=2) mpsFileName = argv[1]; |
---|
70 | int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); |
---|
71 | assert(numMpsReadErrors==0); |
---|
72 | double time1 = CoinCpuTime(); |
---|
73 | |
---|
74 | solver1.initialSolve(); |
---|
75 | |
---|
76 | std::cout<<mpsFileName<<" took "<<CoinCpuTime()-time1<<" seconds, " |
---|
77 | <<" with objective " |
---|
78 | <<solver1.getObjValue() |
---|
79 | <<std::endl; |
---|
80 | |
---|
81 | return 0; |
---|
82 | } |
---|