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
module Var = Var
module Term = Term
module Poly = Poly
module Cnstr = Constraint
module Obj = Objective
module Problem = Problem
module Pclass = Problem.Pclass
let c = Poly.c
let var = Poly.var
let binary = Poly.binary
let range = Poly.range
let range2 = Poly.range2
let range3 = Poly.range3
let rangeb = Poly.rangeb
let range2b = Poly.range2b
let range3b = Poly.range3b
let rangev = Poly.rangev
let range2v = Poly.range2v
let range3v = Poly.range3v
let concat = Poly.concat
let of_float_array = Poly.of_float_array
let zero = Poly.zero
let one = Poly.one
let ( ~-- ) = Poly.( ~-- )
let ( ++ ) = Poly.( ++ )
let ( -- ) = Poly.( -- )
let expand = Poly.expand
let ( *~ ) = Poly.( *~ )
let dot = Poly.dot
let ( *@ ) = Poly.( *@ )
let div = Poly.div
let ( /~ ) = Poly.( /~ )
let eq = Constraint.eq
let ( =~ ) = Constraint.( =~ )
let lt = Constraint.lt
let ( <~ ) = Constraint.( <~ )
let gt = Constraint.gt
let ( >~ ) = Constraint.( >~ )
let maximize = Objective.maximize
let minimize = Objective.minimize
let validate = Problem.validate
let classify = Problem.classify
let vname_list = Problem.vname_list
let to_string = Problem.to_string
let of_string s =
let lexbuf = Lexing.from_string s in
Lpfile.emit (Parser.sections Lexer.token lexbuf)
let read file =
let ch = open_in file in
try
let lexbuf = Lexing.from_channel ch in
let problem = Lpfile.emit (Parser.sections Lexer.token lexbuf) in
close_in ch ; problem
with e -> close_in_noerr ch ; raise e
let write ?(short = false) file problem =
let ch = open_out file in
Printf.fprintf ch "%s\n" (Problem.to_string ~short problem) ;
close_out ch