Commit d9c57a2d authored by Jonas Seidel's avatar Jonas Seidel

reformat output to be compatible with polymake & update correct script

parent f3d47464
use application "polytope";
my $import = lp2poly(".data/Maintenance_Problem/mp");
#print "\n\n---------------------------------------------------------------------------------------------------------\n";
#print "Extreme points relaxed polyeder:\n\n";
my $polyeder = new Polytope<Rational>($import);
$polyeder->FACETS;
print_constraints($polyeder);
#print_constraints($polyeder);
#print $polyeder->VERTICES;
print "\n\n---------------------------------------------------------------------------------------------------------\n";
print "Facets of lattice points convex hull: (varies widely in runtime; you might want to restart if excessively long)\n\n";
my $polyeder2 = new Polytope<Rational>(POINTS=>$import->LATTICE_POINTS, COORDINATE_LABELS=>$import->COORDINATE_LABELS);
print_constraints($polyeder2);
#print "\n\n---------------------------------------------------------------------------------------------------------\n";
#print "Extreme points of lattice points convex hull:\n\n";
#print $polyeder2->VERTICES;
......@@ -43,11 +43,16 @@ std::ostream& operator<<(std::ostream& os, Constraint& constraint){
for(size_t index = constraint.lhs_first_variable(); index < constraint.lhs_end(); index++){
if(std::abs(constraint.lhs_coefficient(index)) > 1e-100){
empty = false;
if(add_plus){
if(constraint.lhs_coefficient(index) < 0){
os << " - ";
}else if(add_plus){
os << " + ";
}
add_plus = true;
os << "(" << constraint.lhs_coefficient(index) << ")" << " x" << index;
if(std::abs(std::abs(constraint.lhs_coefficient(index)) - 1) > 1e-100){
os << std::abs(constraint.lhs_coefficient(index)) << " ";
}
os << "x" << index;
}
}
}
......
......@@ -65,11 +65,16 @@ std::ostream& operator<<(std::ostream& os, Linear_Program& linear_program){
for(size_t index = linear_program.direction_start(); index < linear_program.direction_end(); index++){
if(std::abs(linear_program.direction_coefficient(index)) > 1e-100){
empty = false;
if(add_plus){
if(linear_program.direction_coefficient(index) < 0){
os << " - ";
}else if(add_plus){
os << " + ";
}
add_plus = true;
os << "(" << linear_program.direction_coefficient(index) << ")" << " x" << index;
if(std::abs(std::abs(linear_program.direction_coefficient(index)) - 1) > 1e-100){
os << std::abs(linear_program.direction_coefficient(index)) << " ";
}
os << "x" << index;
}
}
}
......
......@@ -11,12 +11,12 @@ int main(){
random_graph_generator<CircSelectNodeFields, CircSelectEdgeFields>(
{{Flow, Attribute(max, 0)}, {Demand, Attribute(fix, 0)}, {Capacity, Attribute(fix, 1)}, {Critical, Attribute(fix, 0)}},
{},
3,
random_attribute_generator<CircSelectEdgeFields>({ {Capacity, {Continuous, 0, 5}} }),
4,
random_attribute_generator<CircSelectEdgeFields>({ {Capacity, {Continuous, 0, 5}} }),
7,
random_attribute_generator<CircSelectNodeFields>({})
),
2, 2
3, 2
);
while(true){
......@@ -27,7 +27,7 @@ int main(){
ofs << mp << std::endl;
std::cout << mp << std::endl;
ofs.close();
system("polymake --script .data/Maintenance_Problem/pm_script_lp2facets");
std::cin.ignore();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment