genmodel 0.0.32 → 0.0.33
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 +4 -4
- data/ext/Genmodel/GenModel.h +1 -0
- data/ext/Genmodel/GenModelBase.cpp +57 -0
- data/ext/Genmodel/Genmodel.cpp +43 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841759fecd601b6fe9986e0066c9719a556a4d56
|
4
|
+
data.tar.gz: 1813d26c133f042f4f46936f1e99947dc57e6f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bdf45893f13bccd8b9243c1039f09f67f023f88e0c16b757f570e5032710e5b611dd031dd13590768f4f3ba133f75bcb06f34a6f4e0d16e1edd2d32ddb11966
|
7
|
+
data.tar.gz: a4aad7481b5da167147239fa0c907586336e656856e3188e22ec075f3d5c403a9fb4048a90df2250a40614dec38607deba62013b4dc1ac960e1393a2643890aa
|
data/ext/Genmodel/GenModel.h
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
#include <math.h>
|
4
4
|
#include <time.h>
|
5
5
|
|
6
|
+
#define GM_RED "\x1b[31m"
|
7
|
+
#define GM_GREEN "\x1b[32m"
|
8
|
+
#define GM_YELLOW "\x1b[33m"
|
9
|
+
#define GM_BLUE "\x1b[34m"
|
10
|
+
#define GM_MAGENTA "\x1b[35m"
|
11
|
+
#define GM_CYAN "\x1b[36m"
|
12
|
+
#define GM_RESET "\x1b[0m"
|
13
|
+
|
6
14
|
GenModel::GenModel()
|
7
15
|
{
|
8
16
|
version = "genmodel-0.0.24 build 0001";
|
@@ -31,28 +39,77 @@ double GenModel::FindConstraintMinLhs(long row)
|
|
31
39
|
return total;
|
32
40
|
}
|
33
41
|
|
42
|
+
long GenModel::PrintRowInfo(long row)
|
43
|
+
{
|
44
|
+
printf(GM_GREEN "%s : " GM_RESET, consts[row].name.c_str());
|
45
|
+
for(int i = 0; i < int(consts[row].cols.size()); i++)
|
46
|
+
{
|
47
|
+
if(i==0)
|
48
|
+
printf(GM_RED "%f" GM_CYAN "*" GM_RESET "%s", consts[row].coefs[i], vars.name[consts[row].cols[i]].c_str());
|
49
|
+
else
|
50
|
+
printf(GM_CYAN " + " GM_RED "%f" GM_CYAN "*" GM_RESET "%s", consts[row].coefs[i], vars.name[consts[row].cols[i]].c_str());
|
51
|
+
}
|
52
|
+
|
53
|
+
printf(GM_CYAN "%c" GM_RED " %f" GM_RESET "\n", ( consts[row].sense == 'L' ? '<' : (consts[row].sense == 'E' ? '=' : '>')), consts[row].lrhs );
|
54
|
+
printf(GM_GREEN "%s : " GM_RESET, consts[row].name.c_str());
|
55
|
+
|
56
|
+
double min_val = 0.0;
|
57
|
+
double max_val = 0.0;
|
58
|
+
|
59
|
+
for(int i = 0; i < int(consts[row].cols.size()); i++)
|
60
|
+
{
|
61
|
+
double low = consts[row].coefs[i]*vars.lb[consts[row].cols[i]];
|
62
|
+
double high = consts[row].coefs[i]*vars.ub[consts[row].cols[i]];
|
63
|
+
min_val += low;
|
64
|
+
max_val += high;
|
65
|
+
if(i==0)
|
66
|
+
printf("[" GM_RED "%f" GM_GREEN "%f" GM_RESET "]", low, high);
|
67
|
+
else
|
68
|
+
printf(GM_CYAN " + " GM_RESET "[" GM_RED "%f" GM_GREEN "%f" GM_RESET "]", low, high);
|
69
|
+
}
|
70
|
+
printf("%c [" GM_RED "%f " GM_RESET "%f " GM_GREEN "%f" GM_RESET "\n\n", ( consts[row].sense == 'L' ? '<' : (consts[row].sense == 'E' ? '=' : '>')), min_val, consts[row].lrhs, max_val );
|
71
|
+
|
72
|
+
return 0;
|
73
|
+
}
|
74
|
+
|
34
75
|
long GenModel::MakeConstraintFeasible(long row)
|
35
76
|
{
|
36
77
|
if(consts[row].sense == 'L')
|
37
78
|
{
|
38
79
|
double min = FindConstraintMinLhs(row);
|
39
80
|
if(min > consts[row].lrhs)
|
81
|
+
{
|
40
82
|
consts[row].lrhs = min;
|
83
|
+
if(boolParam.count("log_output_stdout") > 0 && boolParam["log_output_stdout"])
|
84
|
+
PrintRowInfo(row);
|
85
|
+
}
|
41
86
|
}
|
42
87
|
else if(consts[row].sense == 'G')
|
43
88
|
{
|
44
89
|
double max = FindConstraintMaxLhs(row);
|
45
90
|
if(max < consts[row].lrhs)
|
91
|
+
{
|
46
92
|
consts[row].lrhs = max;
|
93
|
+
if(boolParam.count("log_output_stdout") > 0 && boolParam["log_output_stdout"])
|
94
|
+
PrintRowInfo(row);
|
95
|
+
}
|
47
96
|
}
|
48
97
|
else if(consts[row].sense == 'R')
|
49
98
|
{
|
50
99
|
double min = FindConstraintMinLhs(row);
|
51
100
|
double max = FindConstraintMaxLhs(row);
|
52
101
|
if(max < consts[row].lrhs)
|
102
|
+
{
|
53
103
|
consts[row].lrhs = max;
|
104
|
+
if(boolParam.count("log_output_stdout") > 0 && boolParam["log_output_stdout"])
|
105
|
+
PrintRowInfo(row);
|
106
|
+
}
|
54
107
|
else if(min > consts[row].urhs)
|
108
|
+
{
|
55
109
|
consts[row].urhs = min;
|
110
|
+
if(boolParam.count("log_output_stdout") > 0 && boolParam["log_output_stdout"])
|
111
|
+
PrintRowInfo(row);
|
112
|
+
}
|
56
113
|
}
|
57
114
|
|
58
115
|
return 0;
|
data/ext/Genmodel/Genmodel.cpp
CHANGED
@@ -31195,6 +31195,48 @@ fail:
|
|
31195
31195
|
}
|
31196
31196
|
|
31197
31197
|
|
31198
|
+
SWIGINTERN VALUE
|
31199
|
+
_wrap_GenModel_PrintRowInfo(int argc, VALUE *argv, VALUE self) {
|
31200
|
+
GenModel *arg1 = (GenModel *) 0 ;
|
31201
|
+
long arg2 ;
|
31202
|
+
void *argp1 = 0 ;
|
31203
|
+
int res1 = 0 ;
|
31204
|
+
long val2 ;
|
31205
|
+
int ecode2 = 0 ;
|
31206
|
+
long result;
|
31207
|
+
VALUE vresult = Qnil;
|
31208
|
+
|
31209
|
+
if ((argc < 1) || (argc > 1)) {
|
31210
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
|
31211
|
+
}
|
31212
|
+
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GenModel, 0 | 0 );
|
31213
|
+
if (!SWIG_IsOK(res1)) {
|
31214
|
+
SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "GenModel *","PrintRowInfo", 1, self ));
|
31215
|
+
}
|
31216
|
+
arg1 = reinterpret_cast< GenModel * >(argp1);
|
31217
|
+
ecode2 = SWIG_AsVal_long(argv[0], &val2);
|
31218
|
+
if (!SWIG_IsOK(ecode2)) {
|
31219
|
+
SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "long","PrintRowInfo", 2, argv[0] ));
|
31220
|
+
}
|
31221
|
+
arg2 = static_cast< long >(val2);
|
31222
|
+
{
|
31223
|
+
try {
|
31224
|
+
result = (long)(arg1)->PrintRowInfo(arg2);
|
31225
|
+
}
|
31226
|
+
catch(string str) {
|
31227
|
+
SWIG_exception(SWIG_RuntimeError,str.c_str());
|
31228
|
+
}
|
31229
|
+
catch(...) {
|
31230
|
+
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
|
31231
|
+
}
|
31232
|
+
}
|
31233
|
+
vresult = SWIG_From_long(static_cast< long >(result));
|
31234
|
+
return vresult;
|
31235
|
+
fail:
|
31236
|
+
return Qnil;
|
31237
|
+
}
|
31238
|
+
|
31239
|
+
|
31198
31240
|
SWIGINTERN VALUE
|
31199
31241
|
_wrap_GenModel_binit_set(int argc, VALUE *argv, VALUE self) {
|
31200
31242
|
GenModel *arg1 = (GenModel *) 0 ;
|
@@ -42615,6 +42657,7 @@ SWIGEXPORT void Init_Genmodel(void) {
|
|
42615
42657
|
rb_define_method(SwigClassGenModel.klass, "FindConstraintMaxLhs", VALUEFUNC(_wrap_GenModel_FindConstraintMaxLhs), -1);
|
42616
42658
|
rb_define_method(SwigClassGenModel.klass, "FindConstraintMinLhs", VALUEFUNC(_wrap_GenModel_FindConstraintMinLhs), -1);
|
42617
42659
|
rb_define_method(SwigClassGenModel.klass, "MakeConstraintFeasible", VALUEFUNC(_wrap_GenModel_MakeConstraintFeasible), -1);
|
42660
|
+
rb_define_method(SwigClassGenModel.klass, "PrintRowInfo", VALUEFUNC(_wrap_GenModel_PrintRowInfo), -1);
|
42618
42661
|
rb_define_method(SwigClassGenModel.klass, "binit=", VALUEFUNC(_wrap_GenModel_binit_set), -1);
|
42619
42662
|
rb_define_method(SwigClassGenModel.klass, "binit", VALUEFUNC(_wrap_GenModel_binit_get), -1);
|
42620
42663
|
rb_define_method(SwigClassGenModel.klass, "bcreated=", VALUEFUNC(_wrap_GenModel_bcreated_set), -1);
|