def get_stp_solver(self): allocation_method = self._components.get('allocation_method') solver_name = self._allocation_methods.get(allocation_method) if not solver_name: self.logger.error("The given allocation method is not available") raise ValueError(allocation_method) return STP(solver_name)
def __init__(self, ccu_store, api, stp_solver, allocation_method, round_time=5, **kwargs): self.logger = logging.getLogger("mrs.auctioneer") self.robot_ids = list() self.timetables = dict() self.api = api self.stp = STP(stp_solver) self.allocation_method = allocation_method self.round_time = timedelta(seconds=round_time) self.alternative_timeslots = kwargs.get('alternative_timeslots', False) self.logger.debug("Auctioneer started") self.tasks_to_allocate = dict() self.allocations = list() self.waiting_for_user_confirmation = list() self.round = Round() # TODO: Update zero_timepoint today_midnight = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) self.zero_timepoint = TimeStamp() self.zero_timepoint.timestamp = today_midnight
def load_stn(file_path, stp_solver): with open(file_path) as json_file: stn_dict = json.load(json_file) stn_json = json.dumps(stn_dict) stp = STP(stp_solver) stn = stp.get_stn(stn_json=stn_json) return stp, stn
def setUp(self): # Load the stn as a dictionary with open(STN) as json_file: stn_dict = json.load(json_file) # Convert the dict to a json string stn_json = json.dumps(stn_dict) self.stp = STP('fpc') self.stn = self.stp.get_stn(stn_json=stn_json)
def __init__(self, robot_id, api, robot_store, stp_solver, task_type): self.id = robot_id self.api = api self.stp = STP(stp_solver) self.timetable = Timetable(robot_id, self.stp) today_midnight = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) self.timetable.zero_timepoint = TimeStamp() self.timetable.zero_timepoint.timestamp = today_midnight
def __init__(self, ccu_store, api, stp_solver, freeze_window, **kwargs): self.logger = logging.getLogger('mrs.dispatcher') self.api = api self.stp = STP(stp_solver) self.freeze_window = timedelta(minutes=freeze_window) self.re_allocate = kwargs.get('re_allocate', False) self.robot_ids = list() self.scheduler = Scheduler(self.stp) self.logger.debug("Dispatcher started")
def from_dict(timetable_dict): robot_id = timetable_dict['robot_id'] stp_solver = STP(timetable_dict['solver_name']) timetable = Timetable(robot_id, stp_solver) stn_cls = timetable.stp_solver.get_stn() ztp = timetable_dict.get('ztp') timetable.ztp = TimeStamp.from_str(ztp) timetable.stn = stn_cls.from_dict(timetable_dict['stn']) timetable.dispatchable_graph = stn_cls.from_dict(timetable_dict['dispatchable_graph']) timetable.stn_tasks = timetable_dict['stn_tasks'] return timetable
import json from stn.stp import STP STNU = "data/stnu_two_tasks.json" if __name__ == '__main__': with open(STNU) as json_file: stnu_dict = json.load(json_file) # Convert the dict to a json string stnu_json = json.dumps(stnu_dict) stp = STP('dsc_lp') stn = stp.get_stn(stn_json=stnu_json) print(stn) stn_dict = stn.to_dict() print(stn_dict) print(type(stn_dict['nodes'][0]['data']))