Example: Linear program
Profiles: OSCAR v1.0, OSCAR v1.1, OSCAR v1.2, OSCAR v1.3, OSCAR v1.4, OSCAR v1.5, OSCAR v1.6, OSCAR v1.7, OSCAR v1.8
We take the matrix
$$ A:= \left( \begin{array}{ccc} 31 & 24 & 78\\ 63 & 17 & 35\\ 99 & 19 & 34 \end{array} \right) $$
with entries in the rational numbers $\mathbb{Q}$.
Now we take the following two vector with entries in $\mathbb{Q}$:
$$ b := (12, 51, 23)\ \mbox{ and }\ w := (64449, 26552, 73367). $$
Now find $x\in\mathbb{Q}^3$ such that $A\cdot x\ge -b$ and $\langle x,w\rangle$ becomes minimal.
Related Specification
Systems
CPLEX
Generate code (generate.sh) [ edit ]
update me
Data outputs
Profiles: default
Data file: data.lp
MINIMIZE
obj: +64449 x1 +26552 x2 +73367 x3
Subject To
ie0: +31 x1 +24 x2 +78 x3 >= -12
ie1: +63 x1 +17 x2 +35 x3 >= -51
ie2: +99 x1 +19 x2 +34 x3 >= -23
BOUNDS
x1 free
x2 free
x3 free
END
Oscar.jl
Generate code (generate.jl) [ edit ]
using Oscar
A = matrix(QQ,[31 24 78; 63 17 35; 99 19 34]);
b = [12, 51, 23]
P = polyhedron(-A, b)
println(vertices(P))
w = [64449, 26552, 73367]
LP = linear_program(P,w;k=0,convention = :min)
println(optimal_value(LP))
save("data.mrdi", LP)
Data outputs
Profiles: OSCAR v1.0, OSCAR v1.1, OSCAR v1.2, OSCAR v1.3, OSCAR v1.4, OSCAR v1.5, OSCAR v1.6, OSCAR v1.7
Data file: data.mrdi
{
"_ns": {"Oscar": ["https://github.com/oscar-system/Oscar.jl", "1.7.0"]},
"_type": {"name": "LinearProgram", "params": {"_type": "QQField"}},
"data": {
"feasible_region": {
"COMBINATORIAL_DIM": 3,
"_info": {
"credits": {
"ppl": " The Parma Polyhedra Library ([[wiki:external_software#PPL]]): A C++ library for convex polyhedra\n and other numerical abstractions.\n http://www.cs.unipr.it/ppl/\n",
"cdd": "\nCopyright by Komei Fukuda.\nhttps://people.inf.ethz.ch/fukudak/cdd_home/\n"
}
},
"_vertex_indices": [4],
"FULL_DIM": true,
"N_VERTICES": 4,
"LINEALITY_DIM": 0,
"_type": "polytope::Polytope<Rational>",
"AFFINE_HULL": [{"cols": 4}],
"EQUATIONS": [{"cols": 4}],
"FEASIBLE": true,
"VERTICES": [
["0", "1", "-3829/486", "985/486"],
["0", "-1", "3334/333", "-1787/666"],
["0", "1", "-441/29", "162/29"],
["1", "7248/2951", "-236125/8853", "62650/8853"]
],
"_ns": {"polymake": ["https://polymake.org", "4.15"]},
"CONE_AMBIENT_DIM": 4,
"INEQUALITIES": [
["12", "31", "24", "78"],
["51", "63", "17", "35"],
["23", "99", "19", "34"],
["1", "0", "0", "0"]
],
"LP": [
{
"MINIMAL_VERTEX": ["1", "7248/2951", "-236125/8853", "62650/8853"],
"MINIMAL_VALUE": "-30698",
"LINEAR_OBJECTIVE": ["0", "64449", "26552", "73367"],
"_attrs": {"convention": {"attachment": true}},
"convention": "min",
"_id": "unnamed#0"
}
],
"POINTED": true,
"BOUNDED": false,
"_attrs": {"_vertex_indices": {"_type": "Vector<Int>", "attachment": true}},
"FAR_FACE": [0, 1, 2],
"CONE_DIM": 4,
"LINEALITY_SPACE": [{"cols": 4}]
},
"convention": "min",
"lpcoeffs": {
"_ns": {"polymake": ["https://polymake.org", "4.15"]},
"data": ["0", "64449", "26552", "73367"],
"_type": "common::Vector<Rational>"
}
}
}
This serialized output is equivalent for these profiles up to UUID renaming and recorded namespace version strings.
cdd
Generate code (generate.sh) [ edit ]
scdd data.ine
Data outputs
Profiles: default
Data file: data.ine
H-representation
begin
3 4 rational
12 31 24 78
51 63 17 35
23 99 19 34
end
minimize
0 64449 26552 73367
polymake
Generate code (generate.pl) [ edit ]
use strict;
use warnings;
use application "polytope";
my $A = new Matrix<Rational>([[31,24,78],[63,17,35],[99,19,34]]);
my $b = new Vector<Rational>([12, 51, 23]);
my $w = new Vector<Rational>([64449, 26552, 73367]);
my $P = new Polytope(INEQUALITIES=>($b|$A));
my $lp = $P->LP(LINEAR_OBJECTIVE=>zero_vector(1)|$w);
save_data($P, "data.json");
Data outputs
Profiles: default
Data file: data.json
{
"LP": [{"LINEAR_OBJECTIVE": ["0", "64449", "26552", "73367"], "_id": "unnamed#0"}],
"_id": "data.json",
"INEQUALITIES": [
["12", "31", "24", "78"],
["51", "63", "17", "35"],
["23", "99", "19", "34"],
["1", "0", "0", "0"]
],
"_type": "polytope::Polytope<Rational>",
"CONE_AMBIENT_DIM": 4,
"_ns": {"polymake": ["https://polymake.org", "4.14"]}
}