# Path: hylaa/timerutil.py
# class Timers():
#     '''
#     a static class for doing timer messuarements. Use
#     Timers.tic(name) and Timers.tic(name) to start and stop timers, use
#     print_stats to print time statistics
#     '''
# 
#     top_level_timer = None
# 
#     stack = [] # stack of currently-running timers, parents at the start, children at the end
# 
#     def __init__(self):
#         raise RuntimeError('Timers is a static class; should not be instantiated')
# 
#     @staticmethod
#     def reset():
#         'reset all timers'
# 
#         Timers.top_level_timer = None
#         Timers.stack = []
# 
#     @staticmethod
#     def tic(name):
#         'start a timer'
# 
#         #print("Tic({})".format(name))
# 
#         if not Timers.stack:
#             top = Timers.top_level_timer
# 
#             if top is not None and top.name != name:
#                 # overwrite old top level timer
#                 #print("Overwriting old top-level timer {} with new top-level timer {}".format(top.name, name))
#                 top = Timers.top_level_timer = None
# 
#             td = top
#         else:
#             td = Timers.stack[-1].get_child(name)
# 
#         # create timer object if it doesn't exist
#         if td is None:
#             parent = None if not Timers.stack else Timers.stack[-1]
#             td = TimerData(name, parent)
# 
#             if not Timers.stack:
#                 Timers.top_level_timer = td
#             else:
#                 Timers.stack[-1].children.append(td)
# 
#         td.tic()
#         Timers.stack.append(td)
# 
#     @staticmethod
#     def toc(name):
#         'stop a timer'
# 
#         #print("Toc({})".format(name))
# 
#         assert Timers.stack[-1].name == name, "Out of order toc(). Expected to first stop timer {}".format(
#             Timers.stack[-1].full_name())
# 
#         Timers.stack[-1].toc()
#         Timers.stack.pop()
# 
#     @staticmethod
#     def print_stats():
#         'print statistics about performance timers to stdout'
# 
#         Timers.print_stats_recursive(Timers.top_level_timer, 0, None)
# 
#     @staticmethod
#     def print_stats_recursive(td, level, total_time):
#         'recursively print information about a timer'
# 
#         low_threshold = 5.0
#         high_threshold = 50.0
# 
#         if level == 0:
#             total_time = td.total_secs
# 
#         percent_total = 100 * td.total_secs / total_time
# 
#         if percent_total < low_threshold:
#             def print_func(text):
#                 'below threshold print function'
# 
#                 return cprint(text, 'grey')
#         elif percent_total > high_threshold:
#             def print_func(text):
#                 'above threshold print function'
# 
#                 return cprint(text, None, attrs=['bold'])
#         else:
#             def print_func(text):
#                 'within threshold print function'
# 
#                 return cprint(text, None)
# 
#         if td.last_start_time is not None:
#             raise RuntimeError("Timer was never stopped: {}".format(td.name))
# 
#         if td.parent is None:
#             percent = 100
#             percent_str = ""
#         else:
#             percent = 100 * td.total_secs / td.parent.total_secs
#             percent_str = " ({:.1f}%)".format(percent)
# 
#         print_func("{}{} Time ({} calls): {:.2f} sec{}".format(" " * level * 2, \
#             td.name.capitalize(), td.num_calls, td.total_secs, percent_str))
# 
#         total_children_secs = 0
# 
#         for child in td.children:
#             total_children_secs += child.total_secs
# 
#             Timers.print_stats_recursive(child, level + 1, total_time)
# 
#         if td.children:
#             other = td.total_secs - total_children_secs
#             other_percent = 100 * other / td.total_secs
# 
#             percent_other = other / total_time
# 
#             if percent_other < low_threshold:
#                 def other_print_func(text):
#                     'below threshold print function'
# 
#                     return cprint(text, 'grey')
#             elif percent_other > high_threshold:
#                 def other_print_func(text):
#                     'above threshold print function'
# 
#                     return cprint(text, None, attrs=['bold'])
#             else:
#                 def other_print_func(text):
#                     'within threshold print function'
# 
#                     return cprint(text, None)
# 
#             percent_str = " ({:.1f}%)".format(other_percent)
# 
#             other_print_func("{}Other: {:.2f} sec{}".format(" " * (level + 1) * 2, \
#                 other, percent_str))


import math
import numpy as np
import hylaa.kamenev as kamenev
from scipy.spatial import ConvexHull
from hylaa.timerutil import Timers
        # use bbox to determine acceptable accuracy... might be better to somehow do this
        epsilon = min(bboxw) / 1000.0
        dim_list = [xdim, ydim]

        def supp_point_nd(vec):
            'return a supporting point for the given direction (maximize)'

            assert len(vec) == len(dim_list)

            d = np.zeros((lpi.dims,), dtype=float)
            # negative here because we want to MAXIMIZE not minimize

            for i, dim_index in enumerate(dim_list):
                d[dim_index] = -vec[i]

            lpi.set_minimize_direction(d)

            res = lpi.minimize(columns=[lpi.cur_vars_offset + n for n in range(lpi.dims)])

            rv = []

            for dim in dim_list:
                rv.append(res[dim])

            rv = np.array(rv, dtype=float)

            return rv

        Timers.tic('kamenev.get_verts')
        verts = kamenev.get_verts(len(dim_list), supp_point_nd, epsilon=epsilon)

# Path: hylaa/timerutil.py
# class Timers():
#     '''
#     a static class for doing timer messuarements. Use
#     Timers.tic(name) and Timers.tic(name) to start and stop timers, use
#     print_stats to print time statistics
#     '''
# 
#     top_level_timer = None
# 
#     stack = [] # stack of currently-running timers, parents at the start, children at the end
# 
#     def __init__(self):
#         raise RuntimeError('Timers is a static class; should not be instantiated')
# 
#     @staticmethod
#     def reset():
#         'reset all timers'
# 
#         Timers.top_level_timer = None
#         Timers.stack = []
# 
#     @staticmethod
#     def tic(name):
#         'start a timer'
# 
#         #print("Tic({})".format(name))
# 
#         if not Timers.stack:
#             top = Timers.top_level_timer
# 
#             if top is not None and top.name != name:
#                 # overwrite old top level timer
#                 #print("Overwriting old top-level timer {} with new top-level timer {}".format(top.name, name))
#                 top = Timers.top_level_timer = None
# 
#             td = top
#         else:
#             td = Timers.stack[-1].get_child(name)
# 
#         # create timer object if it doesn't exist
#         if td is None:
#             parent = None if not Timers.stack else Timers.stack[-1]
#             td = TimerData(name, parent)
# 
#             if not Timers.stack:
#                 Timers.top_level_timer = td
#             else:
#                 Timers.stack[-1].children.append(td)
# 
#         td.tic()
#         Timers.stack.append(td)
# 
#     @staticmethod
#     def toc(name):
#         'stop a timer'
# 
#         #print("Toc({})".format(name))
# 
#         assert Timers.stack[-1].name == name, "Out of order toc(). Expected to first stop timer {}".format(
#             Timers.stack[-1].full_name())
# 
#         Timers.stack[-1].toc()
#         Timers.stack.pop()
# 
#     @staticmethod
#     def print_stats():
#         'print statistics about performance timers to stdout'
# 
#         Timers.print_stats_recursive(Timers.top_level_timer, 0, None)
# 
#     @staticmethod
#     def print_stats_recursive(td, level, total_time):
#         'recursively print information about a timer'
# 
#         low_threshold = 5.0
#         high_threshold = 50.0
# 
#         if level == 0:
#             total_time = td.total_secs
# 
#         percent_total = 100 * td.total_secs / total_time
# 
#         if percent_total < low_threshold:
#             def print_func(text):
#                 'below threshold print function'
# 
#                 return cprint(text, 'grey')
#         elif percent_total > high_threshold:
#             def print_func(text):
#                 'above threshold print function'
# 
#                 return cprint(text, None, attrs=['bold'])
#         else:
#             def print_func(text):
#                 'within threshold print function'
# 
#                 return cprint(text, None)
# 
#         if td.last_start_time is not None:
#             raise RuntimeError("Timer was never stopped: {}".format(td.name))
# 
#         if td.parent is None:
#             percent = 100
#             percent_str = ""
#         else:
#             percent = 100 * td.total_secs / td.parent.total_secs
#             percent_str = " ({:.1f}%)".format(percent)
# 
#         print_func("{}{} Time ({} calls): {:.2f} sec{}".format(" " * level * 2, \
#             td.name.capitalize(), td.num_calls, td.total_secs, percent_str))
# 
#         total_children_secs = 0
# 
#         for child in td.children:
#             total_children_secs += child.total_secs
# 
#             Timers.print_stats_recursive(child, level + 1, total_time)
# 
#         if td.children:
#             other = td.total_secs - total_children_secs
#             other_percent = 100 * other / td.total_secs
# 
#             percent_other = other / total_time
# 
#             if percent_other < low_threshold:
#                 def other_print_func(text):
#                     'below threshold print function'
# 
#                     return cprint(text, 'grey')
#             elif percent_other > high_threshold:
#                 def other_print_func(text):
#                     'above threshold print function'
# 
#                     return cprint(text, None, attrs=['bold'])
#             else:
#                 def other_print_func(text):
#                     'within threshold print function'
# 
#                     return cprint(text, None)
# 
#             percent_str = " ({:.1f}%)".format(other_percent)
# 
#             other_print_func("{}Other: {:.2f} sec{}".format(" " * (level + 1) * 2, \
#                 other, percent_str))


# Path: hylaa/lpplot.py
import math
import numpy as np
import hylaa.kamenev as kamenev
from scipy.spatial import ConvexHull
from hylaa.timerutil import Timers

        # use bbox to determine acceptable accuracy... might be better to somehow do this
        epsilon = min(bboxw) / 1000.0
        dim_list = [xdim, ydim]

        def supp_point_nd(vec):
            'return a supporting point for the given direction (maximize)'

            assert len(vec) == len(dim_list)

            d = np.zeros((lpi.dims,), dtype=float)
            # negative here because we want to MAXIMIZE not minimize

            for i, dim_index in enumerate(dim_list):
                d[dim_index] = -vec[i]

            lpi.set_minimize_direction(d)

            res = lpi.minimize(columns=[lpi.cur_vars_offset + n for n in range(lpi.dims)])

            rv = []

            for dim in dim_list:
                rv.append(res[dim])

            rv = np.array(rv, dtype=float)

            return rv

        Timers.tic('kamenev.get_verts')
        verts = kamenev.get_verts(len(dim_list), supp_point_nd, epsilon=epsilon)

        Timers.toc('kamenev.get_verts')