File: LPinterface.hh

package info (click to toggle)
topcom 0.17.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 78,572 kB
  • sloc: cpp: 16,640; sh: 975; makefile: 345; ansic: 40
file content (85 lines) | stat: -rw-r--r-- 1,740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
////////////////////////////////////////////////////////////////////////////////
// 
// LPinterface.hh 
//
//    produced: 2001/10/21 jr
// last change: 2001/10/21 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef LPINTERFACE_HH
#define LPINTERFACE_HH

#include "setoper.h"
#include "Rational.h"

// the following preprocessor magic is necessary because the word `Rational'
// is used in an enum type in the cddlib:

#include "cdd.h"

// we can use three variants of arithmetics in cddlib:

#if defined GMPRATIONAL // GMP Rational
  
inline void dd_set_R(mytype& a, const Rational& b) {
  //  mpq_init(a);
  mpq_set(a, b.get_mpq_t());
}

#elif defined GMPFLOAT // GMP float
  
inline void dd_set_R(mytype& a, const Rational& b) {
  //  mpq_init(a);
  mpq_set(a, double(b));
}

#else // built-in C double 
  
inline void dd_set_R(mytype& a, const Rational& b) {
  a[0] = double(b);
}

#endif

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>

#include "Matrix.hh"
#include "IntegerSet.hh"

class LPinterface {
private:
  dd_ErrorType     _err;
  dd_LPSolverType  _solver;
  dd_LPPtr         _lpptr;
  dd_LPSolutionPtr _solptr; 
  dd_rowrange      _m;
  dd_colrange      _n;
  dd_MatrixPtr     _matrixptr;
  const IntegerSet _support;
private:
  LPinterface();
public:
  // constructors:
  LPinterface(const Matrix&, const IntegerSet&);
  // destructor:
  inline ~LPinterface();
  // functions:
  bool has_interior_point();
};

inline LPinterface::~LPinterface() {
  
  // Free allocated spaces:
  dd_FreeLPSolution(_solptr);
  dd_FreeLPData    (_lpptr);
  dd_FreeMatrix    (_matrixptr);
  dd_free_global_constants();
}

#endif

// eof LPinterface.hh