BlockIPPlatform
 All Classes Files Functions Variables
OsiInterface.h
Go to the documentation of this file.
1 
6 #ifndef OSI_INTERFACE_H
7 #define OSI_INTERFACE_H
8 
9 #ifndef EXPDLL
10 #ifdef WIN32
11 #ifdef OSI_INTERFACE_EXPORTS
12 #define EXPDLL __declspec(dllexport)
13 #else
14 #define EXPDLL __declspec(dllimport)
15 #endif //OSI_INTERFACE_EXPORTS
16 #else
17 #define EXPDLL
18 #endif //WIN32
19 #endif //EXPDLL
20 
21 #include <string>
22 //#include "OsiSolver.h"
23 //#include "OsiSolverInterface.hpp"
24 class OsiSolver;
25 class OsiSolverInterface;
26 
27 using namespace std;
28 
30 class EXPDLL OsiInterface {
31  public:
32  enum SOLVER{CPLEX, XPRESS, GLPK, CLP, CBC, SYMPHONY};
33  enum OPT_STATUS{OPTIMAL_SOLUTION, TIME_LIMIT_INFEAS, TIME_LIMIT_FEAS, FEASIBLE, FIRST_FEASIBLE, INFEASIBLE, OTHERWISE};
34 
35  private:
37 
38  public:
39  // Constructor
40  OsiInterface(SOLVER solver);
41 
42  // Destructor
43  ~OsiInterface();
44 
45  // Set maximum time allowed to solve the problem
46  void setMaxTime(double time);
47 
48  // Get maximum time allowed to solve the problem
49  double getMaxTime();
50 
51  // Set the maximum number of threads that the solver can use to solve the problem
52  void setNumThreads(int numThreads);
53 
54  // Get the maximum number of threads that the solver can use to solve the problem
55  int getNumThreads();
56 
57  // Set if the execution must be stopped at first feasible solution
58  void setFirstFeasible(bool stopAtFirstFeasible);
59 
60  // Get if the execution must be stopped at first feasible solution
61  bool getFirstFeasible();
62 
63  // Set the name of the log file
64  void setLogFileName(char *filename);
65 
66  // Get the name of the log file
67  const char* getLogFileName();
68 
69  // Get solver interface
70  OsiSolverInterface* getSolverInterface();
71 
72  // Load a problem from a mps file
73  void readMps(const char *filename);
74 
75  // Load a problem
76  void loadProblem(int numRows, int numColumns, int nz, double obj[], double qobj[], double lb[], double ub[],
77  double lhs[], double rhs[], int begRows[], int indCols[], double values[], bool copy_vectors=true);
78 
79  // Solve the problem loaded
80  OPT_STATUS solve();
81 
82  // Get the objective function value
83  double getObjValue();
84 
85  // Get the solution
86  const double* getSolution();
87 
88  // Get the number of variables
89  int getNumVars();
90 
91  // Get the name of variables
92  const string* getVarNames();
93 
94  private:
95  // Free all allocated memory
96  void freeMemory();
97 };
98 
99 #endif //OSI_INTERFACE_H