genmodel 0.0.38 → 0.0.39

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9392b2f09d84cc6fa7bf6de12d1af984eb2edb5a
4
- data.tar.gz: 7e268105f190b3f7a09514b10fa4c78a2519eedd
3
+ metadata.gz: 8604a5483901ff08b6f01aa428fa77371b6807fa
4
+ data.tar.gz: b0d8784902d9ed14df2c3c5a42036408b7ed6235
5
5
  SHA512:
6
- metadata.gz: 86b3e9a97f0fa20b414781fae46a0a0fb81be36d753407d786171402e91cb2c306845174950a37eeafa4ce1a182d5e82348dede6dc790c7adfdd280b2a6f7509
7
- data.tar.gz: 89271f97ad4baf478670aa0a4ef7c5acf8b8af8d8b0ff6d76f0370163a920e0fa061896d72d83a614475b35195d18efa4c04212cbff6c741c99af0615c02b116
6
+ metadata.gz: 512292feef379a74ba2ebf110d13feda9a547d5a7dc64affbee736a05e06c6a53bdc3d7fbc56f91ac309e9cc14eb086c8463bb6874dd46393cb11c83890e9781
7
+ data.tar.gz: e72971d8e500b441e73315ba4d8f68d9346e9e06c003b827a361550d45e06084b0d9fc76c70fbd2cd50f2c31c77cd5fc42a2d4ba68e788776eec3f5347696e89
@@ -91,9 +91,9 @@ class GenModel
91
91
  public:
92
92
  GenModel();
93
93
  virtual ~GenModel() { ClearStructure(); };
94
- long AddIndexToCoef(string coef, string index);
94
+ /*long AddIndexToCoef(string coef, string index);
95
95
  long AddCoef(string coef);
96
- long CoefIndex(string coef, int nargs, ...);
96
+ long CoefIndex(string coef, int nargs, ...);*/
97
97
  long AddConst(string cname);
98
98
  long AddConst(string cname, double rhs, char sense);
99
99
  long AddVar(string nn, double o, double l, double u, char t);
@@ -116,6 +116,7 @@ public:
116
116
  long SetBoolParam(string param, bool val);
117
117
  long SetStrParam(string param, string val);
118
118
  long ThrowError(string error);
119
+ static bool IsAvailable();
119
120
  virtual long Init(string name) = 0;
120
121
  virtual long CreateModel() = 0;
121
122
  virtual long Solve() = 0;
@@ -13,7 +13,7 @@
13
13
 
14
14
  GenModel::GenModel()
15
15
  {
16
- version = "genmodel-0.0.24 build 0001";
16
+ version = "genmodel-0.0.39 build 0001";
17
17
  hassolution = false;
18
18
  bcreated = false;
19
19
  binit = false;
@@ -22,6 +22,11 @@ GenModel::GenModel()
22
22
  solverdata = NULL;
23
23
  }
24
24
 
25
+ bool GenModel::IsAvailable()
26
+ {
27
+ return true;
28
+ }
29
+
25
30
 
26
31
  double GenModel::FindConstraintMaxLhs(long row)
27
32
  {
@@ -19,8 +19,9 @@ GenModelCplex::~GenModelCplex()
19
19
  if (solverdata != NULL) delete static_cast<CplexData*>(solverdata);
20
20
  }
21
21
 
22
- GenModelCplex::GenModelCplex() {
23
-
22
+ bool GenModelCplex::IsAvailable()
23
+ {
24
+ return true;
24
25
  }
25
26
 
26
27
  long GenModelCplex::WriteProblemToLpFile(string filename)
@@ -714,8 +715,8 @@ long GenModelCplex::Clean()
714
715
  #else
715
716
  long cpx_not_implemented() { throw string("The Cplex module is not available on this platform"); }
716
717
 
717
- GenModelCplex::GenModelCplex() {cpx_not_implemented();}
718
718
  GenModelCplex::~GenModelCplex() {cpx_not_implemented();}
719
+ bool GenModelCplex::IsAvailable() {return false;}
719
720
  long GenModelCplex::Init(string name) {return cpx_not_implemented();}
720
721
  long GenModelCplex::CreateModel(string filename, int type, string dn) {return cpx_not_implemented();}
721
722
  long GenModelCplex::CreateModel() {return cpx_not_implemented();}
@@ -64,9 +64,9 @@ public:
64
64
  class GenModelCplex : public GenModel
65
65
  {
66
66
  public:
67
- GenModelCplex();
68
67
  ~GenModelCplex();
69
- long Init(string name);
68
+ static bool IsAvailable();
69
+ long Init(string name);
70
70
  long CreateModel(string filename, int type=0, string dn="");
71
71
  long CreateModel();
72
72
  long AddSolverCol(vector<int>& ind, vector<double>& val, double obj, double lb, double ub, string name, char type = 'C');
@@ -25,6 +25,11 @@ void printmsg(char* msg, GenModelOsi* p)
25
25
  printf("%s", msg);
26
26
  }
27
27
 
28
+ bool GenModelOsi::IsAvailable()
29
+ {
30
+ return true;
31
+ }
32
+
28
33
  long GenModelOsi::WriteProblemToLpFile(string filename)
29
34
  {
30
35
  if(!bcreated)
@@ -854,6 +859,7 @@ long GenModelOsi::Clean()
854
859
 
855
860
  long osi_not_implemented() { throw string("The Osi module is not available on this platform"); }
856
861
 
862
+ bool GenModelOsi::IsAvailable() {return false;}
857
863
  long GenModelOsi::Init(string name) {return osi_not_implemented();}
858
864
  long GenModelOsi::CreateModel() {return osi_not_implemented();}
859
865
  long GenModelOsi::CreateModel(string filename, int type, string dn) {return osi_not_implemented();}
@@ -82,6 +82,7 @@ class GenModelOsi : public GenModel
82
82
  {
83
83
  public:
84
84
  ~GenModelOsi() {if (solverdata != NULL) delete static_cast<OsiData*>(solverdata);}
85
+ static bool IsAvailable();
85
86
  long Init(string name);//, int type=0);
86
87
  long CreateModel();
87
88
  long CreateModel(string filename, int type=0, string dn="");
@@ -2564,10 +2564,8 @@ SWIG_From_ptrdiff_t (ptrdiff_t value)
2564
2564
  #include "GraphTools.h"
2565
2565
  #include "HyperGraph.h"
2566
2566
  #include "BitVector.h"
2567
-
2568
-
2569
- std::vector<double> test;
2570
- vector<double> test1;
2567
+ bool TestCplex(bool mip=true, bool quadratic=false);
2568
+ bool TestOsi(bool mip=true, bool quadratic=false);
2571
2569
 
2572
2570
 
2573
2571
  SWIGINTERNINLINE VALUE
@@ -8401,64 +8399,6 @@ free_swig_Iterator(swig::Iterator *arg1) {
8401
8399
  delete arg1;
8402
8400
  }
8403
8401
 
8404
- SWIGINTERN VALUE
8405
- _wrap_test_get(VALUE self) {
8406
- VALUE _val;
8407
-
8408
- _val = SWIG_NewPointerObj(SWIG_as_voidptr(&test), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 );
8409
- return _val;
8410
- }
8411
-
8412
-
8413
- SWIGINTERN VALUE
8414
- _wrap_test_set(VALUE self, VALUE _val) {
8415
- {
8416
- void *argp = 0;
8417
- int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 );
8418
- if (!SWIG_IsOK(res)) {
8419
- SWIG_exception_fail(SWIG_ArgError(res), "in variable '""test""' of type '""std::vector< double,std::allocator< double > >""'");
8420
- }
8421
- if (!argp) {
8422
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""test""' of type '""std::vector< double,std::allocator< double > >""'");
8423
- } else {
8424
- test = *(reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp));
8425
- }
8426
- }
8427
- return _val;
8428
- fail:
8429
- return Qnil;
8430
- }
8431
-
8432
-
8433
- SWIGINTERN VALUE
8434
- _wrap_test1_get(VALUE self) {
8435
- VALUE _val;
8436
-
8437
- _val = SWIG_NewPointerObj(SWIG_as_voidptr(&test1), SWIGTYPE_p_vectorT_double_t, 0 );
8438
- return _val;
8439
- }
8440
-
8441
-
8442
- SWIGINTERN VALUE
8443
- _wrap_test1_set(VALUE self, VALUE _val) {
8444
- {
8445
- void *argp = 0;
8446
- int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_vectorT_double_t, 0 );
8447
- if (!SWIG_IsOK(res)) {
8448
- SWIG_exception_fail(SWIG_ArgError(res), "in variable '""test1""' of type '""vector< double >""'");
8449
- }
8450
- if (!argp) {
8451
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""test1""' of type '""vector< double >""'");
8452
- } else {
8453
- test1 = *(reinterpret_cast< vector< double > * >(argp));
8454
- }
8455
- }
8456
- return _val;
8457
- fail:
8458
- return Qnil;
8459
- }
8460
-
8461
-
8462
8402
  static swig_class SwigClassULongVector;
8463
8403
 
8464
8404
 
@@ -27125,6 +27065,310 @@ free_std_vector_Sl_std_string_Sg_(std::vector< std::string > *arg1) {
27125
27065
  delete arg1;
27126
27066
  }
27127
27067
 
27068
+ SWIGINTERN VALUE
27069
+ _wrap_TestCplex__SWIG_0(int argc, VALUE *argv, VALUE self) {
27070
+ bool arg1 ;
27071
+ bool arg2 ;
27072
+ bool val1 ;
27073
+ int ecode1 = 0 ;
27074
+ bool val2 ;
27075
+ int ecode2 = 0 ;
27076
+ bool result;
27077
+ VALUE vresult = Qnil;
27078
+
27079
+ if ((argc < 2) || (argc > 2)) {
27080
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
27081
+ }
27082
+ ecode1 = SWIG_AsVal_bool(argv[0], &val1);
27083
+ if (!SWIG_IsOK(ecode1)) {
27084
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "bool","TestCplex", 1, argv[0] ));
27085
+ }
27086
+ arg1 = static_cast< bool >(val1);
27087
+ ecode2 = SWIG_AsVal_bool(argv[1], &val2);
27088
+ if (!SWIG_IsOK(ecode2)) {
27089
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","TestCplex", 2, argv[1] ));
27090
+ }
27091
+ arg2 = static_cast< bool >(val2);
27092
+ {
27093
+ try {
27094
+ result = (bool)TestCplex(arg1,arg2);
27095
+ }
27096
+ catch(string str) {
27097
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27098
+ }
27099
+ catch(...) {
27100
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27101
+ }
27102
+ }
27103
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27104
+ return vresult;
27105
+ fail:
27106
+ return Qnil;
27107
+ }
27108
+
27109
+
27110
+ SWIGINTERN VALUE
27111
+ _wrap_TestCplex__SWIG_1(int argc, VALUE *argv, VALUE self) {
27112
+ bool arg1 ;
27113
+ bool val1 ;
27114
+ int ecode1 = 0 ;
27115
+ bool result;
27116
+ VALUE vresult = Qnil;
27117
+
27118
+ if ((argc < 1) || (argc > 1)) {
27119
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
27120
+ }
27121
+ ecode1 = SWIG_AsVal_bool(argv[0], &val1);
27122
+ if (!SWIG_IsOK(ecode1)) {
27123
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "bool","TestCplex", 1, argv[0] ));
27124
+ }
27125
+ arg1 = static_cast< bool >(val1);
27126
+ {
27127
+ try {
27128
+ result = (bool)TestCplex(arg1);
27129
+ }
27130
+ catch(string str) {
27131
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27132
+ }
27133
+ catch(...) {
27134
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27135
+ }
27136
+ }
27137
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27138
+ return vresult;
27139
+ fail:
27140
+ return Qnil;
27141
+ }
27142
+
27143
+
27144
+ SWIGINTERN VALUE
27145
+ _wrap_TestCplex__SWIG_2(int argc, VALUE *argv, VALUE self) {
27146
+ bool result;
27147
+ VALUE vresult = Qnil;
27148
+
27149
+ if ((argc < 0) || (argc > 0)) {
27150
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
27151
+ }
27152
+ {
27153
+ try {
27154
+ result = (bool)TestCplex();
27155
+ }
27156
+ catch(string str) {
27157
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27158
+ }
27159
+ catch(...) {
27160
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27161
+ }
27162
+ }
27163
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27164
+ return vresult;
27165
+ fail:
27166
+ return Qnil;
27167
+ }
27168
+
27169
+
27170
+ SWIGINTERN VALUE _wrap_TestCplex(int nargs, VALUE *args, VALUE self) {
27171
+ int argc;
27172
+ VALUE argv[2];
27173
+ int ii;
27174
+
27175
+ argc = nargs;
27176
+ if (argc > 2) SWIG_fail;
27177
+ for (ii = 0; (ii < argc); ++ii) {
27178
+ argv[ii] = args[ii];
27179
+ }
27180
+ if (argc == 0) {
27181
+ return _wrap_TestCplex__SWIG_2(nargs, args, self);
27182
+ }
27183
+ if (argc == 1) {
27184
+ int _v;
27185
+ {
27186
+ int res = SWIG_AsVal_bool(argv[0], NULL);
27187
+ _v = SWIG_CheckState(res);
27188
+ }
27189
+ if (_v) {
27190
+ return _wrap_TestCplex__SWIG_1(nargs, args, self);
27191
+ }
27192
+ }
27193
+ if (argc == 2) {
27194
+ int _v;
27195
+ {
27196
+ int res = SWIG_AsVal_bool(argv[0], NULL);
27197
+ _v = SWIG_CheckState(res);
27198
+ }
27199
+ if (_v) {
27200
+ {
27201
+ int res = SWIG_AsVal_bool(argv[1], NULL);
27202
+ _v = SWIG_CheckState(res);
27203
+ }
27204
+ if (_v) {
27205
+ return _wrap_TestCplex__SWIG_0(nargs, args, self);
27206
+ }
27207
+ }
27208
+ }
27209
+
27210
+ fail:
27211
+ Ruby_Format_OverloadedError( argc, 2, "TestCplex",
27212
+ " bool TestCplex(bool mip, bool quadratic)\n"
27213
+ " bool TestCplex(bool mip)\n"
27214
+ " bool TestCplex()\n");
27215
+
27216
+ return Qnil;
27217
+ }
27218
+
27219
+
27220
+ SWIGINTERN VALUE
27221
+ _wrap_TestOsi__SWIG_0(int argc, VALUE *argv, VALUE self) {
27222
+ bool arg1 ;
27223
+ bool arg2 ;
27224
+ bool val1 ;
27225
+ int ecode1 = 0 ;
27226
+ bool val2 ;
27227
+ int ecode2 = 0 ;
27228
+ bool result;
27229
+ VALUE vresult = Qnil;
27230
+
27231
+ if ((argc < 2) || (argc > 2)) {
27232
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
27233
+ }
27234
+ ecode1 = SWIG_AsVal_bool(argv[0], &val1);
27235
+ if (!SWIG_IsOK(ecode1)) {
27236
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "bool","TestOsi", 1, argv[0] ));
27237
+ }
27238
+ arg1 = static_cast< bool >(val1);
27239
+ ecode2 = SWIG_AsVal_bool(argv[1], &val2);
27240
+ if (!SWIG_IsOK(ecode2)) {
27241
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "bool","TestOsi", 2, argv[1] ));
27242
+ }
27243
+ arg2 = static_cast< bool >(val2);
27244
+ {
27245
+ try {
27246
+ result = (bool)TestOsi(arg1,arg2);
27247
+ }
27248
+ catch(string str) {
27249
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27250
+ }
27251
+ catch(...) {
27252
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27253
+ }
27254
+ }
27255
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27256
+ return vresult;
27257
+ fail:
27258
+ return Qnil;
27259
+ }
27260
+
27261
+
27262
+ SWIGINTERN VALUE
27263
+ _wrap_TestOsi__SWIG_1(int argc, VALUE *argv, VALUE self) {
27264
+ bool arg1 ;
27265
+ bool val1 ;
27266
+ int ecode1 = 0 ;
27267
+ bool result;
27268
+ VALUE vresult = Qnil;
27269
+
27270
+ if ((argc < 1) || (argc > 1)) {
27271
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
27272
+ }
27273
+ ecode1 = SWIG_AsVal_bool(argv[0], &val1);
27274
+ if (!SWIG_IsOK(ecode1)) {
27275
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "bool","TestOsi", 1, argv[0] ));
27276
+ }
27277
+ arg1 = static_cast< bool >(val1);
27278
+ {
27279
+ try {
27280
+ result = (bool)TestOsi(arg1);
27281
+ }
27282
+ catch(string str) {
27283
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27284
+ }
27285
+ catch(...) {
27286
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27287
+ }
27288
+ }
27289
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27290
+ return vresult;
27291
+ fail:
27292
+ return Qnil;
27293
+ }
27294
+
27295
+
27296
+ SWIGINTERN VALUE
27297
+ _wrap_TestOsi__SWIG_2(int argc, VALUE *argv, VALUE self) {
27298
+ bool result;
27299
+ VALUE vresult = Qnil;
27300
+
27301
+ if ((argc < 0) || (argc > 0)) {
27302
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
27303
+ }
27304
+ {
27305
+ try {
27306
+ result = (bool)TestOsi();
27307
+ }
27308
+ catch(string str) {
27309
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
27310
+ }
27311
+ catch(...) {
27312
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
27313
+ }
27314
+ }
27315
+ vresult = SWIG_From_bool(static_cast< bool >(result));
27316
+ return vresult;
27317
+ fail:
27318
+ return Qnil;
27319
+ }
27320
+
27321
+
27322
+ SWIGINTERN VALUE _wrap_TestOsi(int nargs, VALUE *args, VALUE self) {
27323
+ int argc;
27324
+ VALUE argv[2];
27325
+ int ii;
27326
+
27327
+ argc = nargs;
27328
+ if (argc > 2) SWIG_fail;
27329
+ for (ii = 0; (ii < argc); ++ii) {
27330
+ argv[ii] = args[ii];
27331
+ }
27332
+ if (argc == 0) {
27333
+ return _wrap_TestOsi__SWIG_2(nargs, args, self);
27334
+ }
27335
+ if (argc == 1) {
27336
+ int _v;
27337
+ {
27338
+ int res = SWIG_AsVal_bool(argv[0], NULL);
27339
+ _v = SWIG_CheckState(res);
27340
+ }
27341
+ if (_v) {
27342
+ return _wrap_TestOsi__SWIG_1(nargs, args, self);
27343
+ }
27344
+ }
27345
+ if (argc == 2) {
27346
+ int _v;
27347
+ {
27348
+ int res = SWIG_AsVal_bool(argv[0], NULL);
27349
+ _v = SWIG_CheckState(res);
27350
+ }
27351
+ if (_v) {
27352
+ {
27353
+ int res = SWIG_AsVal_bool(argv[1], NULL);
27354
+ _v = SWIG_CheckState(res);
27355
+ }
27356
+ if (_v) {
27357
+ return _wrap_TestOsi__SWIG_0(nargs, args, self);
27358
+ }
27359
+ }
27360
+ }
27361
+
27362
+ fail:
27363
+ Ruby_Format_OverloadedError( argc, 2, "TestOsi",
27364
+ " bool TestOsi(bool mip, bool quadratic)\n"
27365
+ " bool TestOsi(bool mip)\n"
27366
+ " bool TestOsi()\n");
27367
+
27368
+ return Qnil;
27369
+ }
27370
+
27371
+
27128
27372
  static swig_class SwigClassModVars;
27129
27373
 
27130
27374
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
@@ -28954,173 +29198,6 @@ free_GenModel(GenModel *arg1) {
28954
29198
  delete arg1;
28955
29199
  }
28956
29200
 
28957
- SWIGINTERN VALUE
28958
- _wrap_GenModel_AddIndexToCoef(int argc, VALUE *argv, VALUE self) {
28959
- GenModel *arg1 = (GenModel *) 0 ;
28960
- string arg2 ;
28961
- string arg3 ;
28962
- void *argp1 = 0 ;
28963
- int res1 = 0 ;
28964
- void *argp2 ;
28965
- int res2 = 0 ;
28966
- void *argp3 ;
28967
- int res3 = 0 ;
28968
- long result;
28969
- VALUE vresult = Qnil;
28970
-
28971
- if ((argc < 2) || (argc > 2)) {
28972
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
28973
- }
28974
- res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GenModel, 0 | 0 );
28975
- if (!SWIG_IsOK(res1)) {
28976
- SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "GenModel *","AddIndexToCoef", 1, self ));
28977
- }
28978
- arg1 = reinterpret_cast< GenModel * >(argp1);
28979
- {
28980
- res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_string, 0 );
28981
- if (!SWIG_IsOK(res2)) {
28982
- SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "string","AddIndexToCoef", 2, argv[0] ));
28983
- }
28984
- if (!argp2) {
28985
- SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "string","AddIndexToCoef", 2, argv[0]));
28986
- } else {
28987
- arg2 = *(reinterpret_cast< string * >(argp2));
28988
- }
28989
- }
28990
- {
28991
- res3 = SWIG_ConvertPtr(argv[1], &argp3, SWIGTYPE_p_string, 0 );
28992
- if (!SWIG_IsOK(res3)) {
28993
- SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "string","AddIndexToCoef", 3, argv[1] ));
28994
- }
28995
- if (!argp3) {
28996
- SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "string","AddIndexToCoef", 3, argv[1]));
28997
- } else {
28998
- arg3 = *(reinterpret_cast< string * >(argp3));
28999
- }
29000
- }
29001
- {
29002
- try {
29003
- result = (long)(arg1)->AddIndexToCoef(arg2,arg3);
29004
- }
29005
- catch(string str) {
29006
- SWIG_exception(SWIG_RuntimeError,str.c_str());
29007
- }
29008
- catch(...) {
29009
- SWIG_exception(SWIG_RuntimeError,"Unknown exception");
29010
- }
29011
- }
29012
- vresult = SWIG_From_long(static_cast< long >(result));
29013
- return vresult;
29014
- fail:
29015
- return Qnil;
29016
- }
29017
-
29018
-
29019
- SWIGINTERN VALUE
29020
- _wrap_GenModel_AddCoef(int argc, VALUE *argv, VALUE self) {
29021
- GenModel *arg1 = (GenModel *) 0 ;
29022
- string arg2 ;
29023
- void *argp1 = 0 ;
29024
- int res1 = 0 ;
29025
- void *argp2 ;
29026
- int res2 = 0 ;
29027
- long result;
29028
- VALUE vresult = Qnil;
29029
-
29030
- if ((argc < 1) || (argc > 1)) {
29031
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
29032
- }
29033
- res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GenModel, 0 | 0 );
29034
- if (!SWIG_IsOK(res1)) {
29035
- SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "GenModel *","AddCoef", 1, self ));
29036
- }
29037
- arg1 = reinterpret_cast< GenModel * >(argp1);
29038
- {
29039
- res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_string, 0 );
29040
- if (!SWIG_IsOK(res2)) {
29041
- SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "string","AddCoef", 2, argv[0] ));
29042
- }
29043
- if (!argp2) {
29044
- SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "string","AddCoef", 2, argv[0]));
29045
- } else {
29046
- arg2 = *(reinterpret_cast< string * >(argp2));
29047
- }
29048
- }
29049
- {
29050
- try {
29051
- result = (long)(arg1)->AddCoef(arg2);
29052
- }
29053
- catch(string str) {
29054
- SWIG_exception(SWIG_RuntimeError,str.c_str());
29055
- }
29056
- catch(...) {
29057
- SWIG_exception(SWIG_RuntimeError,"Unknown exception");
29058
- }
29059
- }
29060
- vresult = SWIG_From_long(static_cast< long >(result));
29061
- return vresult;
29062
- fail:
29063
- return Qnil;
29064
- }
29065
-
29066
-
29067
- SWIGINTERN VALUE
29068
- _wrap_GenModel_CoefIndex(int argc, VALUE *argv, VALUE self) {
29069
- GenModel *arg1 = (GenModel *) 0 ;
29070
- string arg2 ;
29071
- int arg3 ;
29072
- void *arg4 = 0 ;
29073
- void *argp1 = 0 ;
29074
- int res1 = 0 ;
29075
- void *argp2 ;
29076
- int res2 = 0 ;
29077
- int val3 ;
29078
- int ecode3 = 0 ;
29079
- long result;
29080
- VALUE vresult = Qnil;
29081
-
29082
- if (argc < 2) {
29083
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
29084
- }
29085
- res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GenModel, 0 | 0 );
29086
- if (!SWIG_IsOK(res1)) {
29087
- SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "GenModel *","CoefIndex", 1, self ));
29088
- }
29089
- arg1 = reinterpret_cast< GenModel * >(argp1);
29090
- {
29091
- res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_string, 0 );
29092
- if (!SWIG_IsOK(res2)) {
29093
- SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "string","CoefIndex", 2, argv[0] ));
29094
- }
29095
- if (!argp2) {
29096
- SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "string","CoefIndex", 2, argv[0]));
29097
- } else {
29098
- arg2 = *(reinterpret_cast< string * >(argp2));
29099
- }
29100
- }
29101
- ecode3 = SWIG_AsVal_int(argv[1], &val3);
29102
- if (!SWIG_IsOK(ecode3)) {
29103
- SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","CoefIndex", 3, argv[1] ));
29104
- }
29105
- arg3 = static_cast< int >(val3);
29106
- {
29107
- try {
29108
- result = (long)(arg1)->CoefIndex(arg2,arg3,arg4);
29109
- }
29110
- catch(string str) {
29111
- SWIG_exception(SWIG_RuntimeError,str.c_str());
29112
- }
29113
- catch(...) {
29114
- SWIG_exception(SWIG_RuntimeError,"Unknown exception");
29115
- }
29116
- }
29117
- vresult = SWIG_From_long(static_cast< long >(result));
29118
- return vresult;
29119
- fail:
29120
- return Qnil;
29121
- }
29122
-
29123
-
29124
29201
  SWIGINTERN VALUE
29125
29202
  _wrap_GenModel_AddConst__SWIG_0(int argc, VALUE *argv, VALUE self) {
29126
29203
  GenModel *arg1 = (GenModel *) 0 ;
@@ -30640,6 +30717,32 @@ fail:
30640
30717
  }
30641
30718
 
30642
30719
 
30720
+ SWIGINTERN VALUE
30721
+ _wrap_GenModel_IsAvailable(int argc, VALUE *argv, VALUE self) {
30722
+ bool result;
30723
+ VALUE vresult = Qnil;
30724
+
30725
+ if ((argc < 0) || (argc > 0)) {
30726
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
30727
+ }
30728
+ {
30729
+ try {
30730
+ result = (bool)GenModel::IsAvailable();
30731
+ }
30732
+ catch(string str) {
30733
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
30734
+ }
30735
+ catch(...) {
30736
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
30737
+ }
30738
+ }
30739
+ vresult = SWIG_From_bool(static_cast< bool >(result));
30740
+ return vresult;
30741
+ fail:
30742
+ return Qnil;
30743
+ }
30744
+
30745
+
30643
30746
  SWIGINTERN VALUE
30644
30747
  _wrap_GenModel_Init(int argc, VALUE *argv, VALUE self) {
30645
30748
  GenModel *arg1 = (GenModel *) 0 ;
@@ -32644,6 +32747,32 @@ free_GenModelCplex(GenModelCplex *arg1) {
32644
32747
  delete arg1;
32645
32748
  }
32646
32749
 
32750
+ SWIGINTERN VALUE
32751
+ _wrap_GenModelCplex_IsAvailable(int argc, VALUE *argv, VALUE self) {
32752
+ bool result;
32753
+ VALUE vresult = Qnil;
32754
+
32755
+ if ((argc < 0) || (argc > 0)) {
32756
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
32757
+ }
32758
+ {
32759
+ try {
32760
+ result = (bool)GenModelCplex::IsAvailable();
32761
+ }
32762
+ catch(string str) {
32763
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
32764
+ }
32765
+ catch(...) {
32766
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
32767
+ }
32768
+ }
32769
+ vresult = SWIG_From_bool(static_cast< bool >(result));
32770
+ return vresult;
32771
+ fail:
32772
+ return Qnil;
32773
+ }
32774
+
32775
+
32647
32776
  SWIGINTERN VALUE
32648
32777
  _wrap_GenModelCplex_Init(int argc, VALUE *argv, VALUE self) {
32649
32778
  GenModelCplex *arg1 = (GenModelCplex *) 0 ;
@@ -34624,6 +34753,32 @@ free_GenModelOsi(GenModelOsi *arg1) {
34624
34753
  delete arg1;
34625
34754
  }
34626
34755
 
34756
+ SWIGINTERN VALUE
34757
+ _wrap_GenModelOsi_IsAvailable(int argc, VALUE *argv, VALUE self) {
34758
+ bool result;
34759
+ VALUE vresult = Qnil;
34760
+
34761
+ if ((argc < 0) || (argc > 0)) {
34762
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
34763
+ }
34764
+ {
34765
+ try {
34766
+ result = (bool)GenModelOsi::IsAvailable();
34767
+ }
34768
+ catch(string str) {
34769
+ SWIG_exception(SWIG_RuntimeError,str.c_str());
34770
+ }
34771
+ catch(...) {
34772
+ SWIG_exception(SWIG_RuntimeError,"Unknown exception");
34773
+ }
34774
+ }
34775
+ vresult = SWIG_From_bool(static_cast< bool >(result));
34776
+ return vresult;
34777
+ fail:
34778
+ return Qnil;
34779
+ }
34780
+
34781
+
34627
34782
  SWIGINTERN VALUE
34628
34783
  _wrap_GenModelOsi_Init(int argc, VALUE *argv, VALUE self) {
34629
34784
  GenModelOsi *arg1 = (GenModelOsi *) 0 ;
@@ -42472,10 +42627,6 @@ SWIGEXPORT void Init_Genmodel(void) {
42472
42627
  SwigClassIterator.mark = 0;
42473
42628
  SwigClassIterator.destroy = (void (*)(void *)) free_swig_Iterator;
42474
42629
  SwigClassIterator.trackObjects = 0;
42475
- rb_define_singleton_method(mGenmodel, "test", VALUEFUNC(_wrap_test_get), 0);
42476
- rb_define_singleton_method(mGenmodel, "test=", VALUEFUNC(_wrap_test_set), 1);
42477
- rb_define_singleton_method(mGenmodel, "test1", VALUEFUNC(_wrap_test1_get), 0);
42478
- rb_define_singleton_method(mGenmodel, "test1=", VALUEFUNC(_wrap_test1_set), 1);
42479
42630
 
42480
42631
  SwigClassULongVector.klass = rb_define_class_under(mGenmodel, "ULongVector", rb_cObject);
42481
42632
  SWIG_TypeClientData(SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t, (void *) &SwigClassULongVector);
@@ -42805,6 +42956,8 @@ SWIGEXPORT void Init_Genmodel(void) {
42805
42956
  SwigClassStringVector.mark = 0;
42806
42957
  SwigClassStringVector.destroy = (void (*)(void *)) free_std_vector_Sl_std_string_Sg_;
42807
42958
  SwigClassStringVector.trackObjects = 0;
42959
+ rb_define_module_function(mGenmodel, "TestCplex", VALUEFUNC(_wrap_TestCplex), -1);
42960
+ rb_define_module_function(mGenmodel, "TestOsi", VALUEFUNC(_wrap_TestOsi), -1);
42808
42961
 
42809
42962
  SwigClassModVars.klass = rb_define_class_under(mGenmodel, "ModVars", rb_cObject);
42810
42963
  SWIG_TypeClientData(SWIGTYPE_p_ModVars, (void *) &SwigClassModVars);
@@ -42880,9 +43033,6 @@ SWIGEXPORT void Init_Genmodel(void) {
42880
43033
  SwigClassGenModel.klass = rb_define_class_under(mGenmodel, "GenModel", rb_cObject);
42881
43034
  SWIG_TypeClientData(SWIGTYPE_p_GenModel, (void *) &SwigClassGenModel);
42882
43035
  rb_undef_alloc_func(SwigClassGenModel.klass);
42883
- rb_define_method(SwigClassGenModel.klass, "AddIndexToCoef", VALUEFUNC(_wrap_GenModel_AddIndexToCoef), -1);
42884
- rb_define_method(SwigClassGenModel.klass, "AddCoef", VALUEFUNC(_wrap_GenModel_AddCoef), -1);
42885
- rb_define_method(SwigClassGenModel.klass, "CoefIndex", VALUEFUNC(_wrap_GenModel_CoefIndex), -1);
42886
43036
  rb_define_method(SwigClassGenModel.klass, "AddConst", VALUEFUNC(_wrap_GenModel_AddConst), -1);
42887
43037
  rb_define_method(SwigClassGenModel.klass, "AddVar", VALUEFUNC(_wrap_GenModel_AddVar), -1);
42888
43038
  rb_define_method(SwigClassGenModel.klass, "AddVars", VALUEFUNC(_wrap_GenModel_AddVars), -1);
@@ -42902,6 +43052,7 @@ SWIGEXPORT void Init_Genmodel(void) {
42902
43052
  rb_define_method(SwigClassGenModel.klass, "SetBoolParam", VALUEFUNC(_wrap_GenModel_SetBoolParam), -1);
42903
43053
  rb_define_method(SwigClassGenModel.klass, "SetStrParam", VALUEFUNC(_wrap_GenModel_SetStrParam), -1);
42904
43054
  rb_define_method(SwigClassGenModel.klass, "ThrowError", VALUEFUNC(_wrap_GenModel_ThrowError), -1);
43055
+ rb_define_singleton_method(SwigClassGenModel.klass, "IsAvailable", VALUEFUNC(_wrap_GenModel_IsAvailable), -1);
42905
43056
  rb_define_method(SwigClassGenModel.klass, "Init", VALUEFUNC(_wrap_GenModel_Init), -1);
42906
43057
  rb_define_method(SwigClassGenModel.klass, "CreateModel", VALUEFUNC(_wrap_GenModel_CreateModel), -1);
42907
43058
  rb_define_method(SwigClassGenModel.klass, "Solve", VALUEFUNC(_wrap_GenModel_Solve), -1);
@@ -42969,6 +43120,7 @@ SWIGEXPORT void Init_Genmodel(void) {
42969
43120
  SWIG_TypeClientData(SWIGTYPE_p_GenModelCplex, (void *) &SwigClassGenModelCplex);
42970
43121
  rb_define_alloc_func(SwigClassGenModelCplex.klass, _wrap_GenModelCplex_allocate);
42971
43122
  rb_define_method(SwigClassGenModelCplex.klass, "initialize", VALUEFUNC(_wrap_new_GenModelCplex), -1);
43123
+ rb_define_singleton_method(SwigClassGenModelCplex.klass, "IsAvailable", VALUEFUNC(_wrap_GenModelCplex_IsAvailable), -1);
42972
43124
  rb_define_method(SwigClassGenModelCplex.klass, "Init", VALUEFUNC(_wrap_GenModelCplex_Init), -1);
42973
43125
  rb_define_method(SwigClassGenModelCplex.klass, "CreateModel", VALUEFUNC(_wrap_GenModelCplex_CreateModel), -1);
42974
43126
  rb_define_method(SwigClassGenModelCplex.klass, "AddSolverCol", VALUEFUNC(_wrap_GenModelCplex_AddSolverCol), -1);
@@ -42997,6 +43149,7 @@ SWIGEXPORT void Init_Genmodel(void) {
42997
43149
  SWIG_TypeClientData(SWIGTYPE_p_GenModelOsi, (void *) &SwigClassGenModelOsi);
42998
43150
  rb_define_alloc_func(SwigClassGenModelOsi.klass, _wrap_GenModelOsi_allocate);
42999
43151
  rb_define_method(SwigClassGenModelOsi.klass, "initialize", VALUEFUNC(_wrap_new_GenModelOsi), -1);
43152
+ rb_define_singleton_method(SwigClassGenModelOsi.klass, "IsAvailable", VALUEFUNC(_wrap_GenModelOsi_IsAvailable), -1);
43000
43153
  rb_define_method(SwigClassGenModelOsi.klass, "Init", VALUEFUNC(_wrap_GenModelOsi_Init), -1);
43001
43154
  rb_define_method(SwigClassGenModelOsi.klass, "CreateModel", VALUEFUNC(_wrap_GenModelOsi_CreateModel), -1);
43002
43155
  rb_define_method(SwigClassGenModelOsi.klass, "AddSolverRow", VALUEFUNC(_wrap_GenModelOsi_AddSolverRow), -1);
@@ -0,0 +1,232 @@
1
+ /***************************************************************************
2
+ * Test.cpp
3
+ * An application to test GenModel
4
+ *
5
+ * January 8 11:32 2014
6
+ * Copyright 2014 Mathieu Bouchard
7
+ * mathbouchard@gmail.com
8
+ ****************************************************************************/
9
+
10
+
11
+ #include <stdio.h>
12
+ #include <stdlib.h>
13
+ #include <string>
14
+ #include <vector>
15
+ #include <dlfcn.h>
16
+ #ifdef CPLEX_MODULE
17
+ #include "GenModelCplex.h"
18
+ #endif
19
+ #ifdef OSI_MODULE
20
+ #include "GenModelOsi.h"
21
+ #endif
22
+ using namespace std;
23
+
24
+ bool TestCplex(bool mip=true, bool quadratic=false)
25
+ {
26
+ #ifdef CPLEX_MODULE
27
+ try {
28
+
29
+
30
+ printf("*********** Testing done ***********\n");
31
+
32
+ printf("Solving problem from Integer Programming book p.130\n\n");
33
+ printf("z = max 4 x1 - 1 x2\n");
34
+ printf(" 7 x1 - 2 x2 <= 14\n");
35
+ printf(" 1 x2 <= 3\n");
36
+ printf(" 2 x1 - 2 x2 <= 3\n\n");
37
+ printf("The problem has the optimal solution x=(2,1/2) with objective value 7.5\n\n");
38
+
39
+ char version[] = "print_version";
40
+ char epgap[] = "relative_mip_gap_tolerance";
41
+ char timelimit[] = "time_limit";
42
+ char probname[] = "Genmodel Test";
43
+ char problem_type[] = "mip";
44
+ char problem_objective[] = "maximize";
45
+ char log_param[] = "log_file";
46
+ char log_file[] = "tmp/test.log";
47
+ char lp_file[] = "tmp/test.lp";
48
+ char sol_file[] = "tmp/test.sol";
49
+ char qp_string[] = "qp_mat";
50
+ char x1[] = "x1";
51
+ char x2[] = "x2";
52
+ char c1[] = "c1";
53
+ char c2[] = "c2";
54
+ char c3[] = "c3";
55
+
56
+ printf("Initializing problem... ");
57
+
58
+ GenModelCplex solver;
59
+ printf("done.\n");
60
+
61
+ printf("Setting problem... ");
62
+ if(mip)
63
+ solver.SetBoolParam(problem_type, true);
64
+ if(quadratic)
65
+ solver.SetBoolParam(qp_string, true);
66
+ solver.SetBoolParam(version, true);
67
+ solver.SetBoolParam(problem_objective, true);
68
+ solver.SetDblParam(timelimit, 120);
69
+ solver.SetDblParam(epgap, 0.01);
70
+ solver.SetStrParam(log_param,log_file);
71
+ solver.AddVar(x1, 4.0, 0.0, numeric_limits<double>::infinity(), (mip ? 'I' : 'C'));
72
+ if(quadratic)
73
+ solver.SetQpCoef(0,0,-2.5);
74
+ solver.AddVar(x2, -1.0, 0.0, numeric_limits<double>::infinity(), 'C');
75
+
76
+ solver.AddConst(c1, 14.0, 'L');
77
+ solver.AddNzToLast(0, 7.0);
78
+ solver.AddNzToLast(1, -2.0);
79
+
80
+ solver.AddConst(c2, 3.0, 'L');
81
+ solver.AddNzToLast(1, 1.0);
82
+
83
+ solver.AddConst(c3, 3.0, 'L');
84
+ solver.AddNzToLast(0, 2.0);
85
+ solver.AddNzToLast(1, -2.0);
86
+
87
+ printf("done.\n");
88
+ printf("Building problem... ");
89
+ solver.SetNumbers();
90
+ solver.Init(probname);
91
+ solver.CreateModel();
92
+ printf("done.\n");
93
+ printf("Solving problem... ");
94
+ solver.Solve();
95
+ solver.SetSol();
96
+ printf("done.\n");
97
+ printf("Retrieving objective value... ");
98
+ bool has_solution = solver.hassolution;
99
+ double objective_value = solver.objval;
100
+ int solution_status = solver.solstat;
101
+ printf("done.\n");
102
+ printf("solution_status=%ld\nhas_solution=%d\nobjective_value=%f\n", solution_status, has_solution, objective_value);
103
+
104
+ printf("Writing to lp file... ");
105
+ solver.WriteProblemToLpFile(lp_file);
106
+ printf("done.\n");
107
+ printf("Writing to solution file... ");
108
+ solver.WriteSolutionToFile(sol_file);
109
+ printf("done.\n");
110
+
111
+
112
+ printf("Solution:\n");
113
+ for(int i = 0; i < solver.nc; i++)
114
+ printf("x_%d -> %f [rc = %f]\n", i, solver.vars.sol[i], (mip ? -numeric_limits<double>::infinity() : solver.vars.rc[i]));
115
+
116
+ for(int i = 0; i < 3; i++)
117
+ printf("c_%d -> %f [slack = %f]\n", i, (mip ? -numeric_limits<double>::infinity() : solver.consts[i].dual), (mip ? -numeric_limits<double>::infinity() : solver.consts[i].slack));
118
+
119
+ } catch (string e) {
120
+ printf("%s\n",e.c_str());
121
+ }
122
+ return true;
123
+ #else
124
+ printf("Cplex module not available\n");
125
+ throw string("Cplex module not available");
126
+ return false;
127
+ #endif
128
+ }
129
+
130
+ bool TestOsi(bool mip=true, bool quadratic=false)
131
+ {
132
+ #ifdef OSI_MODULE
133
+ try {
134
+ printf("*********** Testing done ***********\n");
135
+
136
+ printf("Solving problem from Integer Programming book p.130\n\n");
137
+ printf("z = max 4 x1 - 1 x2\n");
138
+ printf(" 7 x1 - 2 x2 <= 14\n");
139
+ printf(" 1 x2 <= 3\n");
140
+ printf(" 2 x1 - 2 x2 <= 3\n\n");
141
+ printf("The problem has the optimal solution x=(2,1/2) with objective value 7.5\n\n");
142
+
143
+ char version[] = "print_version";
144
+ char epgap[] = "relative_mip_gap_tolerance";
145
+ char timelimit[] = "time_limit";
146
+ char probname[] = "Genmodel Test";
147
+ char problem_type[] = "mip";
148
+ char problem_objective[] = "maximize";
149
+ char log_param[] = "log_file";
150
+ char log_file[] = "tmp/test.log";
151
+ char lp_file[] = "tmp/test.lp";
152
+ char sol_file[] = "tmp/test.sol";
153
+ char qp_string[] = "qp_mat";
154
+ char x1[] = "x1";
155
+ char x2[] = "x2";
156
+ char c1[] = "c1";
157
+ char c2[] = "c2";
158
+ char c3[] = "c3";
159
+
160
+ printf("Initializing problem... ");
161
+
162
+ GenModelOsi solver;
163
+ printf("done.\n");
164
+
165
+ printf("Setting problem... ");
166
+ if(mip)
167
+ solver.SetBoolParam(problem_type, true);
168
+ if(quadratic)
169
+ solver.SetBoolParam(qp_string, true);
170
+ solver.SetBoolParam(version, true);
171
+ solver.SetBoolParam(problem_objective, true);
172
+ solver.SetDblParam(timelimit, 120);
173
+ solver.SetDblParam(epgap, 0.01);
174
+ solver.SetStrParam(log_param,log_file);
175
+ solver.AddVar(x1, 4.0, 0.0, numeric_limits<double>::infinity(), (mip ? 'I' : 'C'));
176
+ if(quadratic)
177
+ solver.SetQpCoef(0,0,-2.5);
178
+ solver.AddVar(x2, -1.0, 0.0, numeric_limits<double>::infinity(), 'C');
179
+
180
+ solver.AddConst(c1, 14.0, 'L');
181
+ solver.AddNzToLast(0, 7.0);
182
+ solver.AddNzToLast(1, -2.0);
183
+
184
+ solver.AddConst(c2, 3.0, 'L');
185
+ solver.AddNzToLast(1, 1.0);
186
+
187
+ solver.AddConst(c3, 3.0, 'L');
188
+ solver.AddNzToLast(0, 2.0);
189
+ solver.AddNzToLast(1, -2.0);
190
+
191
+ printf("done.\n");
192
+ printf("Building problem... ");
193
+ solver.SetNumbers();
194
+ solver.Init(probname);
195
+ solver.CreateModel();
196
+ printf("done.\n");
197
+ printf("Solving problem... ");
198
+ solver.Solve();
199
+ solver.SetSol();
200
+ printf("done.\n");
201
+ printf("Retrieving objective value... ");
202
+ bool has_solution = solver.hassolution;
203
+ double objective_value = solver.objval;
204
+ int solution_status = solver.solstat;
205
+ printf("done.\n");
206
+ printf("solution_status=%ld\nhas_solution=%d\nobjective_value=%f\n", solution_status, has_solution, objective_value);
207
+
208
+ printf("Writing to lp file... ");
209
+ solver.WriteProblemToLpFile(lp_file);
210
+ printf("done.\n");
211
+ printf("Writing to solution file... ");
212
+ solver.WriteSolutionToFile(sol_file);
213
+ printf("done.\n");
214
+
215
+
216
+ printf("Solution:\n");
217
+ for(int i = 0; i < solver.nc; i++)
218
+ printf("x_%d -> %f [rc = %f]\n", i, solver.vars.sol[i], (mip ? -numeric_limits<double>::infinity() : solver.vars.rc[i]));
219
+
220
+ for(int i = 0; i < 3; i++)
221
+ printf("c_%d -> %f [slack = %f]\n", i, (mip ? -numeric_limits<double>::infinity() : solver.consts[i].dual), (mip ? -numeric_limits<double>::infinity() : solver.consts[i].slack));
222
+
223
+ } catch (string e) {
224
+ printf("%s\n",e.c_str());
225
+ }
226
+ return true;
227
+ #else
228
+ printf("Osi module not available\n");
229
+ throw string("Osi module not available");
230
+ return false;
231
+ #endif
232
+ }
@@ -202,7 +202,7 @@ if is_darwin
202
202
  #end
203
203
 
204
204
  elsif is_linux
205
- # path = Dir.home+"/ibm/ILOG/CPLEX_Studio126/cplex/include:/opt/ibm/ILOG/CPLEX_Studio126/cplex/include"
205
+
206
206
  path = "/opt/ibm/ILOG/CPLEX_Studio126/cplex/include"
207
207
  puts "Looking for ilcplex/cplex.h in "+path
208
208
  if(is_cplex && find_header("ilcplex/cplex.h",path))
@@ -217,6 +217,33 @@ elsif is_linux
217
217
  end
218
218
  end
219
219
 
220
+ search_path = "/opt/ibm/ILOG/"
221
+ search_file = "/libcplex.a"
222
+ puts "Looking for libcplex.a in "+search_path+"/*"
223
+ file_exist = nil
224
+ if file_exist == nil && File.exist?(search_path)
225
+ Find.find(search_path) do |path|
226
+ if (FileTest.directory?(path))
227
+ puts path+search_file
228
+ #temp_name = (path).gsub(/\/usr\/local\/Cellar\/cbc\//,'')
229
+ #temp_name = (path).gsub(/\/usr\/local\/Cellar\/coinmp\//,'')
230
+ #count = temp_name.count('/')
231
+ count = 0
232
+ if ((count == 0) && (File.exist?(path+search_file)))
233
+ file_exist = "#{path}"
234
+ break
235
+ end
236
+ end
237
+ end
238
+ end
239
+ puts "Looking for libcplex (function CPXopenCPLEX) in "+file_exist
240
+ if(is_cplex && find_library("cplex","main",file_exist)) #"CPXopenCPLEX",path))
241
+ puts "found"
242
+ else
243
+ puts "not found"
244
+ is_cplex = false
245
+ end
246
+
220
247
  path = "/usr/lib:/usr/local/lib/"
221
248
  puts "Looking for pthread (function main) in "+path
222
249
  if(find_library("pthread",nil,path))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genmodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Bouchard
@@ -34,6 +34,7 @@ files:
34
34
  - ext/Genmodel/HyperGraph.h
35
35
  - ext/Genmodel/ProblemReaderOsi.cpp
36
36
  - ext/Genmodel/ProblemReaderOsi.h
37
+ - ext/Genmodel/Test.cpp
37
38
  - ext/Genmodel/extconf.rb
38
39
  - ext/Genmodel/mygraph.cpp
39
40
  - ext/Genmodel/mygraph.h