gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix GLPK tests (#213)
0 4 0
default
4 files changed with 14 insertions and 0 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -513,24 +513,28 @@
513 513
    default:
514 514
      LEMON_ASSERT(false, "Wrong sense");
515 515
      return GlpkBase::Sense();
516 516
    }
517 517
  }
518 518

	
519 519
  void GlpkBase::_clear() {
520 520
    glp_erase_prob(lp);
521 521
    rows.clear();
522 522
    cols.clear();
523 523
  }
524 524

	
525
  void GlpkBase::freeEnv() {
526
    glp_free_env();
527
  }
528

	
525 529
  // GlpkLp members
526 530

	
527 531
  GlpkLp::GlpkLp()
528 532
    : LpBase(), GlpkBase(), LpSolver() {
529 533
    messageLevel(MESSAGE_NO_OUTPUT);
530 534
  }
531 535

	
532 536
  GlpkLp::GlpkLp(const GlpkLp& other)
533 537
    : LpBase(other), GlpkBase(other), LpSolver(other) {
534 538
    messageLevel(MESSAGE_NO_OUTPUT);
535 539
  }
536 540

	
Ignore white space 24 line context
... ...
@@ -93,24 +93,32 @@
93 93
    virtual void _getObjCoeffs(InsertIterator b) const;
94 94

	
95 95
    virtual void _setObjCoeff(int i, Value obj_coef);
96 96
    virtual Value _getObjCoeff(int i) const;
97 97

	
98 98
    virtual void _setSense(Sense);
99 99
    virtual Sense _getSense() const;
100 100

	
101 101
    virtual void _clear();
102 102

	
103 103
  public:
104 104

	
105
    /// \brief Deallocates the globally allocated memory of GLPK.
106

	
107
    /// Deallocates the globally allocated memory of GLPK.  \note
108
    /// Usually, it do not have to be called, because the GLPK use
109
    /// only a small amount of global memory, and it is deallocated
110
    /// automatically at the end of program.
111
    static void freeEnv();
112

	
105 113
    ///Pointer to the underlying GLPK data structure.
106 114
    LPX *lpx() {return lp;}
107 115
    ///Const pointer to the underlying GLPK data structure.
108 116
    const LPX *lpx() const {return lp;}
109 117

	
110 118
    ///Returns the constraint identifier understood by GLPK.
111 119
    int lpxRow(Row r) const { return rows(id(r)); }
112 120

	
113 121
    ///Returns the variable identifier understood by GLPK.
114 122
    int lpxCol(Col c) const { return cols(id(c)); }
115 123

	
116 124
  };
Ignore white space 6 line context
... ...
@@ -357,24 +357,25 @@
357 357

	
358 358
int main()
359 359
{
360 360
  LpSkeleton lp_skel;
361 361
  lpTest(lp_skel);
362 362

	
363 363
#ifdef HAVE_GLPK
364 364
  {
365 365
    GlpkLp lp_glpk1,lp_glpk2;
366 366
    lpTest(lp_glpk1);
367 367
    aTest(lp_glpk2);
368 368
  }
369
  GlpkLp::freeEnv();
369 370
#endif
370 371

	
371 372
#ifdef HAVE_CPLEX
372 373
  try {
373 374
    CplexLp lp_cplex1,lp_cplex2;
374 375
    lpTest(lp_cplex1);
375 376
    aTest(lp_cplex2);
376 377
  } catch (CplexEnv::LicenseError& error) {
377 378
#ifdef LEMON_FORCE_CPLEX_CHECK
378 379
    check(false, error.what());
379 380
#else
380 381
    std::cerr << error.what() << std::endl;
Ignore white space 6 line context
... ...
@@ -106,24 +106,25 @@
106 106

	
107 107
}
108 108

	
109 109

	
110 110
int main()
111 111
{
112 112

	
113 113
#ifdef HAVE_GLPK
114 114
  {
115 115
    GlpkMip mip1;
116 116
    aTest(mip1);
117 117
  }
118
  GlpkLp::freeEnv();
118 119
#endif
119 120

	
120 121
#ifdef HAVE_CPLEX
121 122
  try {
122 123
    CplexMip mip2;
123 124
    aTest(mip2);
124 125
  } catch (CplexEnv::LicenseError& error) {
125 126
#ifdef LEMON_FORCE_CPLEX_CHECK
126 127
    check(false, error.what());
127 128
#else
128 129
    std::cerr << error.what() << std::endl;
129 130
    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
0 comments (0 inline)