#!/usr/bin/env python

from opaal.lattices.maxplus_polyhedron import *

"""
This calculates the abovementioned LHS and RHSes, for 3D polyhedra. Usage: copy
to top-level opaal directory, edit the convex generators and exceeded bounds
(those not exceeded are not important) and run. If the result should be correct
can be verified by MPRenderer or my MPP drawing script.
"""

# convex generators
gen = [(1,1,1), (3,3,1), (3,3,3)]
# only the exceeded bounds
bounds = {0: 2}

mpp = MaxPlusPolyhedron(len(gen[0]),gen)

reset_only = mpp.reset(bounds)
print "P_reset = ", reset_only

intersection_then_reset = mpp
for coord in bounds:
    intersection_then_reset = intersection_then_reset.add(bounds[coord], "le", coord)
intersection_then_reset = intersection_then_reset.reset(bounds)
print "P_iirr  = ", intersection_then_reset

interleaved = mpp
for coord in bounds:
    interleaved = interleaved.add(bounds[coord], "le", coord)
    interleaved = interleaved.reset({coord: bounds[coord]})
print "P_irir  = ", interleaved

