-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathppl_ops.pl
130 lines (100 loc) · 3.03 KB
/
ppl_ops.pl
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
:- module(ppl_ops, [
start_ppl/0,
end_ppl/0,
getConstraint/2,
addConstraints/2,
addConstraint/2,
makePolyhedron/2,
copyPolyhedron/2,
satisfiable/2,
project/3,
equivalent/2,
disjointFrom/2,
contains/2,
consistent/2,
convhull/3,
widenPolyhedraH79/2,
widenPolyhedraBHRZ03/2,
widenUptoH79/3,
widenUptoBHRZ03/3,
isEmpty/1,
mapCoords/2,
rankingFunction_PR/2,
rankingFunction_MS/2,
allRankingFunctions_PR/2,
polyhedronDimension/2,
maximizeExpr/4,
minimizeExpr/4,
dropNonIntegerPoint/1
], [assertions, isomodes, doccomments]).
%! \title Constraint relations using PPL
:- use_module(library(ppl)).
getConstraint(H,Cs0) :-
ppl_Polyhedron_get_minimized_constraints(H,Cs0).
addConstraints(H,C):-
ppl_Polyhedron_add_constraints(H,C).
addConstraint(H,C):-
ppl_Polyhedron_add_constraint(H,C).
makePolyhedron(Cs,H1) :-
ppl_new_NNC_Polyhedron_from_constraints(Cs,H1).
copyPolyhedron(H1,H2) :-
ppl_new_NNC_Polyhedron_from_NNC_Polyhedron(H1,H2).
satisfiable(Cs,H1) :-
ppl_new_NNC_Polyhedron_from_constraints(Cs,H1),
\+ ppl_Polyhedron_is_empty(H1).
project(H,Zs,H) :-
ppl_Polyhedron_remove_space_dimensions(H,Zs).
equivalent(H0,H1) :-
ppl_Polyhedron_equals_Polyhedron(H0,H1).
disjointFrom(H0,H1) :-
ppl_Polyhedron_is_disjoint_from_Polyhedron(H0,H1).
contains(H0,_) :-
ppl_Polyhedron_is_universe(H0),
!.
contains(H0,H1) :-
ppl_Polyhedron_contains_Polyhedron(H0,H1).
consistent(H0,H1) :-
copyPolyhedron(H0,H2),
ppl_Polyhedron_intersection_assign(H2,H1),
\+ ppl_Polyhedron_is_empty(H2).
convhull(empty,H1,H1) :-
!.
convhull(H1,empty,H1) :-
!.
convhull(H0,H1,H2) :-
ppl_Polyhedron_poly_hull_assign(H1,H0),
H2 = H1.
widenPolyhedraH79(H0,H1) :-
ppl_Polyhedron_H79_widening_assign(H0,H1).
widenPolyhedraBHRZ03(H0,H1) :-
ppl_Polyhedron_BHRZ03_widening_assign(H0,H1).
widenUptoH79(H0,H1,Cs) :-
ppl_Polyhedron_bounded_H79_extrapolation_assign(H0,H1,Cs).
widenUptoBHRZ03(H0,H1,Cs) :-
ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign(H0,H1,Cs).
isEmpty(H) :-
ppl_Polyhedron_is_empty(H).
mapCoords(H,Map) :-
ppl_Polyhedron_map_space_dimensions(H,Map).
rankingFunction_PR(H,F) :-
ppl_one_affine_ranking_function_PR_NNC_Polyhedron(H,F).
rankingFunction_MS(H,F) :-
ppl_one_affine_ranking_function_MS_NNC_Polyhedron(H,F).
allRankingFunctions_PR(H,F) :-
ppl_all_affine_ranking_functions_PR_NNC_Polyhedron(H,F).
polyhedronDimension(H,K) :-
ppl_Polyhedron_space_dimension(H,K).
maximizeExpr(P, Expr, CoNum, CoDen):-
ppl_Polyhedron_maximize(P, Expr, CoNum, CoDen, _).
minimizeExpr(P, Expr, CoNum, CoDen):-
ppl_Polyhedron_minimize(P, Expr, CoNum, CoDen, _).
dropNonIntegerPoint(H0):-
ppl_Polyhedron_drop_some_non_integer_points(H0,polynomial).
start_ppl :-
ppl_initialize.
%ppl_version(Pv),
%write('PPL version used: '),
%write(Pv),
%nl.
end_ppl :-
ppl_finalize.