Exemplo n.º 1
0
 def __get_state_by_monotonic_function_from_queue(self, function, value,
                                                  rounding="closest"):
     '''
     Get a state from the queue only by measure function and desired value.
     
     The function must by a monotonic rising function on the timeline.
     
     See documentation of garlicsim.general_misc.binary_search.binary_search
     for details about rounding options.
     '''
     assert rounding in ["high", "low", "exact", "both", "closest"]
     queue = self.cruncher.work_queue
     queue_as_list = queue_tools.queue_as_list(queue)
     # todo: Probably inefficient, should access them one by one
     
     return binary_search.binary_search\
            (queue_as_list, function, value, rounding)
Exemplo n.º 2
0
 def __get_state_by_monotonic_function_from_queue(
     self, function, value, rounding=binary_search.CLOSEST):
     '''
     Get a state from the queue only by measure function and desired value.
     
     The function must by a monotonic rising function on the timeline.
     
     See documentation of garlicsim.general_misc.binary_search.roundings for
     details about rounding options.
     '''
     assert issubclass(rounding, binary_search.Rounding)
     queue = self.cruncher.work_queue
     queue_as_list = queue_tools.queue_as_list(queue)
     # todo: Probably inefficient, should access them one by one
     
     return binary_search.binary_search\
            (queue_as_list, function, value, rounding)
Exemplo n.º 3
0
 def __get_state_by_monotonic_function_from_queue(
     self, function, value, rounding=binary_search.CLOSEST):
     '''
     Get a state from the queue only by measure function and desired value.
     
     The function must by a monotonic rising function on the timeline.
     
     See documentation of `garlicsim.general_misc.binary_search.roundings`
     for details about rounding options.
     '''
     assert issubclass(rounding, binary_search.Rounding)
     queue = self.cruncher.work_queue
     queue_as_list = queue_tools.queue_as_list(queue)
     # todo: Probably inefficient, should access them one by one
     
     return binary_search.binary_search\
            (queue_as_list, function, value, rounding)