Commit e2499d4b by Jonas Seidel

### Polymake script "pm_script_lp2facets" now resprects given integrality and more:

```- Now scans integrality under "General" und calculates the convex hull
wrt these. Previously all variables were assumed integral.
- Adds calculation of projection on Integral Coordinates and subsequent
convex hull.```
parent e57f4aa5
 use application "polytope"; my \$import = lp2poly(".data/Maintenance_Problem/mp"); my \$import = lp2poly(".data/Maintenance_Problem/mp.lp"); #print "\n\n---------------------------------------------------------------------------------------------------------\n"; #print "Extreme points relaxed polyeder:\n\n"; ... ... @@ -13,8 +13,75 @@ my \$polyeder = new Polytope(\$import); 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(POINTS=>\$import->LATTICE_POINTS, COORDINATE_LABELS=>\$import->COORDINATE_LABELS); print_constraints(\$polyeder2); use strict; use warnings; use List::MoreUtils 'first_index'; use List::Util 1.33 'any'; my \$filename = '.data/Maintenance_Problem/mp.lp'; open(my \$fh, '<:encoding(UTF-8)', \$filename) or die "Could not open file '\$filename' \$!"; # determining indexes of descrete variables given in mp.lp my \$integral_str = ""; my \$phase = 0; while (my \$row = <\$fh>) { chomp \$row; if (\$phase == 0 && \$row eq "General") { \$phase = 1; } elsif (\$phase == 1 && \$row eq "End") { last; } elsif (\$phase == 1) { \$integral_str = "\${integral_str} \${row}"; } } my @integral_strs = split(" ", \$integral_str); my \$integral_indexes = []; my \$labels = \$import->COORDINATE_LABELS; for my \$i (0 .. (scalar @integral_strs)-1) { if (any { \$integral_strs[\$i] } @\$labels) { my \$index = first_index { \$integral_strs[\$i] eq \$_ } @\$labels; push @\$integral_indexes, \$index; }else{ print "WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN-WARN\n"; } } # selecting the corresponding labels @\$integral_indexes = sort {\$a <=> \$b} (@\$integral_indexes); #print "@\$integral_indexes\n"; my \$restr_labels = [@\$labels[0]]; for (@\$integral_indexes) { push @\$restr_labels, @\$labels[\$_]; } #print scalar @\$labels; print "\n"; #print scalar @\$integral_indexes; print "\n"; #print scalar @\$restr_labels; print "\n"; #print "@\$labels\n"; #print "@\$restr_labels\n"; # calculating the wanted data: print "Mixed Integer Convex Hull:\n"; my \$mint_hull = mixed_integer_hull(\$import, \$integral_indexes); \$mint_hull->COORDINATE_LABELS = \$import->COORDINATE_LABELS; print_constraints(\$mint_hull); print "Integral Coordinate Projection Convex Hull\n"; my \$proj = projection(\$import, \$integral_indexes); my \$proj_hull = integer_hull(\$proj); \$proj_hull->COORDINATE_LABELS = \$restr_labels; print_constraints(\$proj_hull); #print "check: Integral Coordinate Projection of MI Convex Hull\n"; #my \$mint_proj_hull = integer_hull(projection(\$mint_hull, \$integral_indexes)); #\$mint_proj_hull->COORDINATE_LABELS = \$restr_labels; #print_constraints(\$mint_proj_hull); #print "\n\n---------------------------------------------------------------------------------------------------------\n"; #print "Extreme points of lattice points convex hull:\n\n"; ... ...
 ... ... @@ -6,5 +6,4 @@ ass_test linear_program_test maintenance_problem_test .test .data/Maintenance_Problem/mp .data/.cache/*.lp *.lp
 ... ... @@ -51,7 +51,7 @@ Maintenance_Problem::Maintenance_Problem(CircSelectNetwork& g, CircSelectNode* s } return {{name.str(), Equality, lhs, 0}}; }, {{Flow, {Integral, {true, 0}, {false, 0}}}, {Critical, {Integral, {true, 0}, {true, 1}}}}, {{Flow, {Continuous, {true, 0}, {false, 0}}}, {Critical, {Integral, {true, 0}, {true, 1}}}}, {}, name_appendix.str() )); ... ...
 ... ... @@ -11,9 +11,9 @@ int main(){ random_graph_generator( {{Flow, Attribute(max, 0)}, {Demand, Attribute(fix, 0)}, {Capacity, Attribute(fix, 1)}, {Critical, Attribute(fix, 0)}}, {}, 3, random_attribute_generator({ {Capacity, {Continuous, 0, 5}} }), 5, 4, random_attribute_generator({ {Capacity, {Integral, 0, 5}} }), 4, random_attribute_generator({}) ), 3, 2 ... ... @@ -23,7 +23,7 @@ int main(){ Maintenance_Problem mp; mpg >> mp; std::ofstream ofs("./.data/Maintenance_Problem/mp"); std::ofstream ofs("./.data/Maintenance_Problem/mp.lp"); ofs << mp << std::endl; std::cout << mp << std::endl; ofs.close(); ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!