-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIPMinCheck.h
60 lines (49 loc) · 1.04 KB
/
MIPMinCheck.h
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
/*
* MIPMinCheck.h
*
* Created on: Feb 1, 2015
* Author: mushthofa
*/
#ifndef MIPMINCHECK_H_
#define MIPMINCHECK_H_
#include "MinCheck.h"
#include <glpk.h>
#include "MIPRegistry.h"
#include <coin/CbcModel.hpp>
#include <coin/OsiClpSolverInterface.hpp>
const double EPS = 1e-5;
class MIPMinCheck: public MinCheck
{
public:
MIPMinCheck(const Program& p, const FAnswerSet& as)
:MinCheck(), mipreg(p, as)
{
/* Count our target = \Sigma_x a[x]\in AS
* If the objective value z from MIP is s.t.
* |z-target| < EPS
* we got a minimal AS
*/
Inter_t interp = as.getInter();
Inter_t::iterator it;
target = 0;
for(it=interp.begin(); it!=interp.end(); ++it)
{
std::string predName = it->first->getPredicateName();
if(predName.find("_NEW_")!=string::npos)
continue;
target += it->second.getFloat();
}
}
void writeMPS();
bool callMIP();
virtual bool isMinimal()
{
writeMPS();
return callMIP();
}
virtual ~MIPMinCheck() {}
protected:
MIPRegistry mipreg;
double target;
};
#endif /* MIPMINCHECK_H_ */