File: QSOinterface.hh

package info (click to toggle)
topcom 1.1.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 31,784 kB
  • sloc: cpp: 37,616; sh: 4,262; makefile: 497; ansic: 49
file content (111 lines) | stat: -rw-r--r-- 2,709 bytes parent folder | download | duplicates (2)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
////////////////////////////////////////////////////////////////////////////////
// 
// QSOinterface.hh 
//
//    produced: 2020/04/01 jr
// last change: 2020/04/01 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef QSOINTERFACE_HH
#define QSOINTERFACE_HH

#ifdef HAVE_LIBQSOPTEX

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

#include "Vector.hh"
#include "Matrix.hh"
#include "LabelSet.hh"

// QSOPT_ex includes:
extern "C" {
#include "qsopt_ex/QSopt_ex.h"
}

namespace topcom {

  class QSOinterface {
  private:
    // tmp data for the problem description:
    int                _cmatrowdim;
    int                _cmatcoldim;
    int                _cntnze;
    int                _cntnzc;
    int*               _cmatcnt;
    int*               _cmatbeg;
    int*               _cmatind;
    char*              _sense;
    char**             _colnames; 
    char**             _rownames;
    mpq_t*             _cmatval;
    mpq_t*             _obj;
    mpq_t*             _rhs;   
    mpq_t*             _lower;   
    mpq_t*             _upper;
    mpq_QSprob         _lp;
    // tmp data for the results:
    mpq_t*             _ysol;
    mpq_t*             _xsol;
    QSbasis*           _basis;
    // input data needed for the output of heights for *each* point:
    int*               _col_of_nzc;
    int*               _nzc_of_col;
    const LabelSet     _support;
    // sync data:
    static bool        _is_initialized;
    static std::mutex  _init_mutex;
  private:
    QSOinterface() {}
    QSOinterface(const QSOinterface&) {}
  public:
    // constructors:
    QSOinterface(const Matrix&, const LabelSet&);

    // destructor:
    ~QSOinterface();

    // QSopt must be initialized and terminated,
    // which is best done only once:
    inline static void init();
    inline static void term();
  
    // functions:
    bool has_interior_point(Vector* heightsptr);
  };

  // QSopt must be initialized and terminated,
  // which is best done only once:
  inline void QSOinterface::init() {
    if (_is_initialized) {
      return;
    }
    if (CommandlineOptions::verbose()) {
      QSopt_ex_version();
    }
    std::lock_guard<std::mutex> init_lock(_init_mutex);
    QSexactStart();
    QSexact_set_precision (128);
    _is_initialized = true;
  }

  inline void QSOinterface::term() {
    if (!_is_initialized) {
      return;
    }
    std::lock_guard<std::mutex> init_lock(_init_mutex);
    // currently the clearance seg-faults -- deactivated:
    // QSexactClear();
    _is_initialized = false;
  }

}; // namespace topcom

#endif // HAVE_LIBQSOPTEX

#endif

// eof QSOinterface.hh