package libzipperposition
Install
Dune Dependency
Authors
Maintainers
Sources
md5=97cdb2f90468e9e27c7bbe3b4fb160bb
sha512=fee73369f673a91dfa9e265fc69be08b32235e10a495f3af6477d404fcd01e3452a0d012b150f3d7f97c00af2f6045019ad039164bf698f70d771231cc4efe5d
doc/libzipperposition.calculi/Libzipperposition_calculi/Simplex/MakeHelp/index.html
Module Simplex.MakeHelp
Source
Parameters
module Var : OrderedType
Signature
Lift an external variable in the var
type
the usual system, but the extended variable type
include S with type var := var
The type of a (possibly not solved) linear system
Generic type returned when solving the simplex. A solution is a list of bindings that satisfies all the constraints inside the system. If the system is unsatisfiable, an explanation of type 'cert
is returned.
An unsatisfiability explanation is a couple (x, expr)
. If expr
is the empty list, then there is a contradiction between two given bounds of x
. Else, the explanation is an equality x = expr
that is valid (it can be derived from the original equations of the system) from which a bound can be deduced which contradicts an already given bound of the system.
and cert_tree =
| Branch of var * Z.t * n_cert * n_cert
| Explanation of k_cert
(*The type of explanation for integer systems. In one case, the system is unsatisfiable when seen as a rational system. In the other case, two cases are considered : for a given variable
*)x
and a boundb
, eitherx
is lower thanb
, or it is greater thenb + 1
.
The type of traces of the optimizations performed on a simplex.
TODO
Simplex construction
add_eq s (x, eq)
returns a system containing the same constraints as s
, plus the equation (x = eq).
add_bounds (x, lower, upper)
returns a system containing the same constraints as s
, plus the bounds lower
and upper
for the given variable x
. If the bound is loose on one side (no upper bounds for instance), the values Zarith.Q.inf
and Zarith.Q.minus_inf
can be used. By default, in a system, all variables have no bounds, i.e have lower bound Zarith.Q.minus_inf
and upper bound Zarith.Q.inf
.
Simplex solving
ksolve s
solves the system s
and returns a solution, if one exists. This function may change the internal representation of the system to that of an equivalent one (permutation of basic and non basic variables and pivot operation on the tableaux).
nsolve s int_vars
solve the system s
considering the variables in int_vars
as integers instead of rationals. There is no guarantee that this function will terminate (for instance, on the system (1 <= 3 * x + 3 * y <= 2
, nsolve
will NOT terminate), it hence recommended to apply a global bounds to the variables of a system before trying to solve it with this function.
safe_nsolve s int_vars
solves the system s
considering the variables in int_vars
as integers. This function always terminate, thanks to a global bound that is applied to all variables of int_vars. The global bound is also returned to allow for verification. Due to the bounds being very high, safe_nsolve
may take a lot of time and memory. It is recommended to apply some optimizations before trying to solve system using this function.
Simplex optimizations
tighten int_vars s
tightens all the bounds of the variables in int_vars
and returns the list of optimizations performed on the system.
normalize int_vars s
, normalizes the system s
(in place), and returns the list of optimizations performed on it. int_vars
is the list of variable that should be assigned an integer. A normalized system has only integer coefficients in his tableaux. Furthermore, in any line (i.e in the expression of a basic variable x
), the gcd of all coefficients is 1
. This includes the bounds of x
, except in the following case. If all pertinent variables (have a non-zero coefficient) in the expression of x
are in int_vars
, then the bounds are divided by the gcd of the coefficients in the expression, and then rounded (since we can deduce that x
must be an integer as well).
Apply the given optimizations to the simplex.
Access functions
get_tab s
returns the current tableaux of s
as a triple (l, l', tab)
where l
is the list of the non-basic variables, l'
the list of basic variables and tab
the list of the rows of the tableaux in the same order as l
and l'
.
get_assign s
returns the current (partial) assignment of the variables in s
as a list of bindings. Only non-basic variables (as given by get_tab
) should appear in this assignent. As such, and according to simplex invariants, all variables in the assignment returned should satisfy their bounds.
get_bounds s x
returns the pair (low, upp)
of the current bounds for the variable x
. Notice that it is possible that low
is strictly greater than upp
.
get_all_bounds s
returns the list of all the explicit bounds of s
. Any variable not present in the return value is assumed to have no bounds (i.e lower bound Zarith.Q.minus_inf
and upper bound Zarith.Q.inf
).
Printing functions
print_debug print_var
returns a suitable function for printing debug info on the current state of a system. It can for instance be used as the debug function of solve
to see the evolution of the simplex.