gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Force cplex checking (#260)
0 2 0
default
2 files changed with 0 insertions and 10 deletions:
↑ Collapse diff ↑
Show white space 96 line context
... ...
@@ -350,77 +350,72 @@
350 350
  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
351 351

	
352 352
  //Erase one constraint and return to maximization
353 353
  lp.erase(upright);
354 354
  lp.sense(lp.MAX);
355 355
  expected_opt=LpSolver::INF;
356 356
  solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt);
357 357

	
358 358
  //Infeasibilty
359 359
  lp.addRow(x1+x2 <=-2);
360 360
  solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt);
361 361

	
362 362
}
363 363

	
364 364
template<class LP>
365 365
void cloneTest()
366 366
{
367 367
  //Test for clone/new
368 368

	
369 369
  LP* lp = new LP();
370 370
  LP* lpnew = lp->newSolver();
371 371
  LP* lpclone = lp->cloneSolver();
372 372
  delete lp;
373 373
  delete lpnew;
374 374
  delete lpclone;
375 375
}
376 376

	
377 377
int main()
378 378
{
379 379
  LpSkeleton lp_skel;
380 380
  lpTest(lp_skel);
381 381

	
382 382
#ifdef HAVE_GLPK
383 383
  {
384 384
    GlpkLp lp_glpk1,lp_glpk2;
385 385
    lpTest(lp_glpk1);
386 386
    aTest(lp_glpk2);
387 387
    cloneTest<GlpkLp>();
388 388
  }
389 389
#endif
390 390

	
391 391
#ifdef HAVE_CPLEX
392 392
  try {
393 393
    CplexLp lp_cplex1,lp_cplex2;
394 394
    lpTest(lp_cplex1);
395 395
    aTest(lp_cplex2);
396 396
    cloneTest<CplexLp>();
397 397
  } catch (CplexEnv::LicenseError& error) {
398
#ifdef LEMON_FORCE_CPLEX_CHECK
399 398
    check(false, error.what());
400
#else
401
    std::cerr << error.what() << std::endl;
402
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
403
#endif
404 399
  }
405 400
#endif
406 401

	
407 402
#ifdef HAVE_SOPLEX
408 403
  {
409 404
    SoplexLp lp_soplex1,lp_soplex2;
410 405
    lpTest(lp_soplex1);
411 406
    aTest(lp_soplex2);
412 407
    cloneTest<SoplexLp>();
413 408
  }
414 409
#endif
415 410

	
416 411
#ifdef HAVE_CLP
417 412
  {
418 413
    ClpLp lp_clp1,lp_clp2;
419 414
    lpTest(lp_clp1);
420 415
    aTest(lp_clp2);
421 416
    cloneTest<ClpLp>();
422 417
  }
423 418
#endif
424 419

	
425 420
  return 0;
426 421
}
Show white space 96 line context
... ...
@@ -98,68 +98,63 @@
98 98
  mip.colType(x2,MipSolver::INTEGER);
99 99
  expected_opt=1.0/2.0;
100 100
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
101 101

	
102 102

	
103 103
  //Restrict both to integer
104 104
  mip.colType(x1,MipSolver::INTEGER);
105 105
  expected_opt=0;
106 106
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
107 107

	
108 108
  //Erase a variable
109 109
  mip.erase(x2);
110 110
  mip.rowUpperBound(y2, 8);
111 111
  expected_opt=1;
112 112
  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
113 113

	
114 114
}
115 115

	
116 116

	
117 117
template<class MIP>
118 118
void cloneTest()
119 119
{
120 120

	
121 121
  MIP* mip = new MIP();
122 122
  MIP* mipnew = mip->newSolver();
123 123
  MIP* mipclone = mip->cloneSolver();
124 124
  delete mip;
125 125
  delete mipnew;
126 126
  delete mipclone;
127 127
}
128 128

	
129 129
int main()
130 130
{
131 131

	
132 132
#ifdef HAVE_GLPK
133 133
  {
134 134
    GlpkMip mip1;
135 135
    aTest(mip1);
136 136
    cloneTest<GlpkMip>();
137 137
  }
138 138
#endif
139 139

	
140 140
#ifdef HAVE_CPLEX
141 141
  try {
142 142
    CplexMip mip2;
143 143
    aTest(mip2);
144 144
    cloneTest<CplexMip>();
145 145
  } catch (CplexEnv::LicenseError& error) {
146
#ifdef LEMON_FORCE_CPLEX_CHECK
147 146
    check(false, error.what());
148
#else
149
    std::cerr << error.what() << std::endl;
150
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
151
#endif
152 147
  }
153 148
#endif
154 149

	
155 150
#ifdef HAVE_CBC
156 151
  {
157 152
    CbcMip mip1;
158 153
    aTest(mip1);
159 154
    cloneTest<CbcMip>();
160 155
  }
161 156
#endif
162 157

	
163 158
  return 0;
164 159

	
165 160
}
0 comments (0 inline)