gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 4 0
merge default
4 files changed with 18 insertions and 0 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -513,24 +513,30 @@
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

	
529
  GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;
530

	
525 531
  // GlpkLp members
526 532

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

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

	
Ignore white space 24 line context
... ...
@@ -91,24 +91,36 @@
91 91

	
92 92
    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
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
  private:
104

	
105
    static void freeEnv();
106

	
107
    struct FreeEnvHelper {
108
      ~FreeEnvHelper() {
109
        freeEnv();
110
      }
111
    };
112
    
113
    static FreeEnvHelper freeEnvHelper;
114
    
103 115
  public:
104 116

	
105 117
    ///Pointer to the underlying GLPK data structure.
106 118
    LPX *lpx() {return lp;}
107 119
    ///Const pointer to the underlying GLPK data structure.
108 120
    const LPX *lpx() const {return lp;}
109 121

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

	
113 125
    ///Returns the variable identifier understood by GLPK.
114 126
    int lpxCol(Col c) const { return cols(id(c)); }
0 comments (0 inline)