clingo[LP]
clingo[LP]
extends the ASP solver clingo
with linear constraints as dealt with in Linear Programming (LP).
Install
Install via conda:
conda install -c potassco -c conda-forge clingo-lp
CPLEX
The clingolp propagator requires an LP solver. The default is lpsolve but cplex can be used optionally.
IBM also provides a promotional version of cplex
that is sufficient to solve small problems limited to 1000 variables and 1000 constraints.
conda install -c ibmdecisionoptimization cplex
To solve larger problems, you need to use the full version of CPLEX Studio.
Syntax
LP constraints can be expressed as follows:
LP constraints | ClingoLP Syntax |
---|---|
w1x1+…+wnxn >= k | &sum{ w1* x1; …; wn* xn} >= k |
domain(x)={l,…,u} | &dom{ l.. u} = x |
maximize: w1x1+…+wnxn | &maximize{ w1* x1; …; wn* x1} (minimize analogous) |
To avoid syntax clashes, you must quote "
real numbers. Instead of 1.5
write "1.5"
.
General usage of clingo[LP]
Basic call:
clingoLP <encoding> <instance> <options>
Example:
clingoLP example_encoding.lp example_instance.lp --show-lp-solution 0
- Options
- –show-lp-solution
- Show LP solution and value of objective function
- –lp-solver=cplx
- Selects a LP solver (default lp-solver=lps)
- –accuracy=n
- Prints n decimal positions (default accuracy=1)
- –epsilon=n,m
- Set epsilon to convert lhs > k into lhs >= k+n*10-m (default epsilon=1,3)
- –strict
- Enables strict semantics
- –trace
- Enables detailed output of theory propagation
- –core-confl=n
- Searches for core conflicts if at least n% of the theory atoms are decided (default core-confl=20)
- –prop-heur=n
- Starts a solve call of the LP solver if at least n% of the theory atoms are decided (default prop-heur=0)
- –ilp
- Sets the LP solver to solve an Integer Linear Programming (ILP) problem
- All clingo options
- Number of solutions controlled via clingo
- –show-lp-solution
Publication
- Tomi Janhunen, Roland Kaminski, Max Ostrowski, Torsten Schaub, Sebastian Schellhorn and Philipp Wanko, Clingo goes Linear Constraints over Reals and Integers, TPLP, 2017: [Experiments]