genmodel 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/Genmodel/GenModel.h +152 -0
- data/ext/Genmodel/GenModelBase.cpp +389 -0
- data/ext/Genmodel/GenModelCplex.cpp +814 -0
- data/ext/Genmodel/GenModelCplex.h +85 -0
- data/ext/Genmodel/GenModelOsi.cpp +892 -0
- data/ext/Genmodel/GenModelOsi.h +96 -0
- data/ext/Genmodel/GenModelOsiInterface.cpp +143 -0
- data/ext/Genmodel/GenModelOsiInterface.h +43 -0
- data/ext/Genmodel/Genmodel.cpp +10789 -0
- data/ext/Genmodel/InterfaceObject.cpp +68 -0
- data/ext/Genmodel/InterfaceObject.h +28 -0
- data/ext/Genmodel/ProblemReaderOsi.cpp +78 -0
- data/ext/Genmodel/ProblemReaderOsi.h +31 -0
- data/ext/Genmodel/extconf.rb +162 -0
- data/lib/Genmodel.rb +5 -0
- metadata +25 -13
- data/lib/genmodel.bundle +0 -0
- data/lib/genmodel.so +0 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
/***************************************************************************
|
2
|
+
* GenModel.h
|
3
|
+
* A generic model creation interface for different solver
|
4
|
+
*
|
5
|
+
* October 5 11:32 2007
|
6
|
+
* Copyright 2007 Mathieu Bouchard
|
7
|
+
* mathbouchard@gmail.com
|
8
|
+
****************************************************************************/
|
9
|
+
|
10
|
+
#ifndef GenModelCplex_H
|
11
|
+
#define GenModelCplex_H
|
12
|
+
|
13
|
+
#if defined WIN64 || defined WIN32
|
14
|
+
#ifndef snprintf
|
15
|
+
#define snprintf sprintf_s
|
16
|
+
#endif
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#include "GenModel.h"
|
20
|
+
#include <ilcplex/cplex.h>
|
21
|
+
|
22
|
+
using namespace std;
|
23
|
+
|
24
|
+
class CplexData
|
25
|
+
{
|
26
|
+
public:
|
27
|
+
CplexData();
|
28
|
+
~CplexData();
|
29
|
+
long Reset();
|
30
|
+
long Delete();
|
31
|
+
long ClearStructure();
|
32
|
+
CPXENVptr env;
|
33
|
+
CPXLPptr lp;
|
34
|
+
int* mat_c;
|
35
|
+
int* mat_r;
|
36
|
+
double* mat_v;
|
37
|
+
double* lrhs;
|
38
|
+
double* urhs;
|
39
|
+
char* sense;
|
40
|
+
double* ub;
|
41
|
+
double* lb;
|
42
|
+
char* type;
|
43
|
+
double* obj;
|
44
|
+
double* x;
|
45
|
+
double* dual;
|
46
|
+
double* rcost;
|
47
|
+
double* slack;
|
48
|
+
char** cname;
|
49
|
+
char** rname;
|
50
|
+
long nc;
|
51
|
+
long nr;
|
52
|
+
long onc;
|
53
|
+
long onr;
|
54
|
+
CPXFILEptr cpxfileptr;
|
55
|
+
};
|
56
|
+
|
57
|
+
class GenModelCplex : public GenModel
|
58
|
+
{
|
59
|
+
public:
|
60
|
+
GenModelCplex();
|
61
|
+
~GenModelCplex();
|
62
|
+
long Init(string name);
|
63
|
+
long CreateModel(string filename, int type=0, string dn="");
|
64
|
+
long CreateModel();
|
65
|
+
long AddSolverCol(vector<int>& ind, vector<double>& val, double obj, double lb, double ub, string name, char type = 'C');
|
66
|
+
long AddSolverRow(vector<int>& ind, vector<double>& val, double rhs, char sense, string name);
|
67
|
+
long AddCol(int* newi, double* newcol, int nz, double obj, double lb, double ub, const char* name, char type = 'C');
|
68
|
+
long AddCut(int* cols, double* vals, int nz, double rhs, char sense, const char* name);
|
69
|
+
long ChangeBulkBounds(int count, int * ind, char * type, double * vals);
|
70
|
+
long ChangeBulkObjectives(int count, int * ind, double * vals);
|
71
|
+
long ChangeBulkNz(int count, int* rind, int* cind, double* vals);
|
72
|
+
long WriteProblemToLpFile(string filename);
|
73
|
+
long WriteSolutionToFile(string filename);
|
74
|
+
long SwitchToMip();
|
75
|
+
long SwitchToLp();
|
76
|
+
long DeleteMipStarts();
|
77
|
+
long Solve();
|
78
|
+
long SetSol();
|
79
|
+
long Clean();
|
80
|
+
double GetMIPRelativeGap();
|
81
|
+
long SetDirectParam(int whichparam, genmodel_param value, string type, string message);
|
82
|
+
long SetParam(string param, int whichparam, string type, string message, bool implemented = true);
|
83
|
+
};
|
84
|
+
|
85
|
+
#endif // GenModelCplex_H
|