scml.scml2019.schedulers ======================== .. py:module:: scml.scml2019.schedulers Classes ------- .. autoapisummary:: scml.scml2019.schedulers.ScheduleInfo scml.scml2019.schedulers.Scheduler scml.scml2019.schedulers.GreedyScheduler Module Contents --------------- .. py:class:: ScheduleInfo .. py:attribute:: final_balance :type: float balance at the end of the schedule .. py:attribute:: valid :type: bool :value: True Is this a valid schedule? .. py:attribute:: start :type: Optional[int] :value: None The starting step of this schedule .. py:attribute:: end :type: Optional[int] :value: None The step after the last step in this simulation .. py:attribute:: needs :type: List[scml.scml2019.common.ProductionNeed] :value: [] The products needed but not still in storage needed to complete this schedule. .. py:attribute:: jobs :type: List[scml.scml2019.common.Job] :value: [] The jobs that need to be scheduled .. py:attribute:: failed_contracts :type: List[negmas.situated.Contract] :value: [] A list of contracts that failed to be scheduled. .. py:attribute:: ignored_contracts :type: List[negmas.situated.Contract] :value: [] A list of contracts ignored for this schedule because they are in the past. .. py:method:: __str__() .. py:method:: combine(other: ScheduleInfo) -> None .. py:class:: Scheduler(manager_id: str, awi: scml.scml2019.awi.SCMLAWI, max_insurance_premium: float = float('inf'), horizon: Optional[int] = None) Bases: :py:obj:`abc.ABC` Base class for all schedulers .. py:attribute:: horizon :value: None .. py:attribute:: n_steps :value: 0 .. py:attribute:: n_lines :value: 0 .. py:attribute:: simulator :type: scml.scml2019.simulators.FactorySimulator | None :value: None .. py:attribute:: products :type: List[scml.scml2019.common.Product] :value: [] .. py:attribute:: processes :type: List[scml.scml2019.common.Process] :value: [] .. py:attribute:: profiles :type: List[scml.scml2019.common.ManufacturingProfileCompiled] :value: [] .. py:attribute:: producing :type: Dict[int, List[scml.scml2019.common.ProductManufacturingInfo]] .. py:attribute:: manager_id .. py:attribute:: awi .. py:attribute:: max_insurance_premium .. py:method:: bookmark() -> int Sets a bookmark to the current location :returns: bookmark ID .. py:method:: rollback(bookmark_id: int) -> bool Rolls back to the given bookmark ID :param bookmark_id The bookmark ID returned from bookmark: Remarks: - You can only rollback in the reverse order of bookmarks. If the bookmark ID given here is not the one at the top of the bookmarks stack, the rollback will fail (return False) .. py:method:: delete_bookmark(bookmark_id: int) -> bool Commits everything since the bookmark so it cannot be rolled back :param bookmark_id The bookmark ID returned from bookmark: Remarks: - You can only rollback in the reverse order of bookmarks. If the bookmark ID given here is not the one at the top of the bookmarks stack, the deletion will fail (return False) .. py:method:: init(simulator: scml.scml2019.simulators.FactorySimulator, products: List[scml.scml2019.common.Product], processes: List[scml.scml2019.common.Process], profiles: List[scml.scml2019.common.ManufacturingProfileCompiled], producing: Dict[int, List[scml.scml2019.common.ProductManufacturingInfo]]) Called by the FactoryManager after it is initialized .. py:method:: schedule(contracts: Collection[negmas.situated.Contract] = (), assume_no_further_negotiations=False, ensure_storage_for: int = 0, start_at: int = 0) -> ScheduleInfo Schedules a set of contracts and returns either the search_for_schedule or None if infeasible :param whatever it has scheduled before. If the state is given: :param it is taken as the initial state for scheduling: :param contracts: The contracts to be scheduled :param assume_no_further_negotiations: whether to assume that more negotiations can take place (to secure :param production needs): :param ensure_storage_for: A minimum time to ensure that products are available in storage before contract delivery :param times: :type times: sell contracts :param start_at: The time at which to start scheduling. No jobs will be scheduled before this time. :returns: `ScheduleInfo` describing the schedulo and any production needs and updates to be carried out. .. py:method:: find_schedule(contracts: Collection[negmas.situated.Contract], start: int, end: int, assume_no_further_negotiations=False, ensure_storage_for: int = 0, start_at: int = 0) -> ScheduleInfo :abstractmethod: Schedules a set of contracts and returns either the search_for_schedule or None if infeasible :param start: :param end: :param contracts: :param assume_no_further_negotiations: :param ensure_storage_for: :param start_at: The time at which to start scheduling. No jobs will be scheduled before this time. :returns: Schedule information (See `ScheduleInfo` for its contents). .. py:class:: GreedyScheduler(manager_id: str, awi: scml.scml2019.awi.SCMLAWI, max_insurance_premium: float = float('inf'), horizon: Optional[int] = None, add_catalog_prices=True, strategy: str = 'latest', profile_sorter: str = 'total-cost>time') Bases: :py:obj:`Scheduler` Default scheduler used by the DefaultFactoryManager .. py:method:: __getstate__() .. py:method:: __setstate__(state) .. py:attribute:: add_catalog_prices :value: True .. py:attribute:: strategy :value: 'latest' .. py:attribute:: fields :type: List[Callable[[scml.scml2019.common.ProductManufacturingInfo], float]] .. py:attribute:: field_order :type: List[int] :value: [] .. py:attribute:: producing :type: Dict[int, List[scml.scml2019.common.ProductManufacturingInfo]] .. py:method:: init(simulator: scml.scml2019.simulators.FactorySimulator, products: List[scml.scml2019.common.Product], processes: List[scml.scml2019.common.Process], profiles: List[scml.scml2019.common.ManufacturingProfileCompiled], producing: Dict[int, List[scml.scml2019.common.ProductManufacturingInfo]]) Called by the FactoryManager after it is initialized .. py:method:: _profile_sorter(info: scml.scml2019.common.ProductManufacturingInfo) -> Any .. py:method:: unit_time(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: total_cost(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: total_unit_cost(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: production_cost(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: production_unit_cost(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: input_cost(info: scml.scml2019.common.ProductManufacturingInfo) .. py:method:: input_unit_cost(info: scml.scml2019.common.ProductManufacturingInfo) -> float .. py:method:: schedule_contract(contract: negmas.situated.Contract, assume_no_further_negotiations=False, end: int = None, ensure_storage_for: int = 0, start_at: int = 0) -> ScheduleInfo Schedules this contract if possible and returns information about the resulting schedule :param contract: The contract being scheduled :param assume_no_further_negotiations: If true no further negotiations will be assumed possible :param end: The scheduling horizon (None for the default). :param ensure_storage_for: The number of steps all needs must be in storage before they are consumed in production :param start_at: No jobs will be scheduled before that time. :returns: Full schedule information including validity, line schedulers, production needs, etc (see `SchedulerInfo`). .. py:method:: schedule_contracts(contracts: Collection[negmas.situated.Contract], end: int = None, assume_no_further_negotiations=False, ensure_storage_for: int = 0, start_at: int = 0) -> ScheduleInfo Schedules a set of contracts and returns the `ScheduleInfo`. :param contracts: Contracts to schedule :param assume_no_further_negotiations: If true, no further negotiations will be assumed to be possible :param end: The end of the simulation for the schedule (exclusive) :param ensure_storage_for: Ensure that the outcome will be at the storage for at least this time :param start_at: The timestep at which to start scheduling :returns: ScheduleInfo giving the schedule after these contracts is included. `valid` member can be used to check whether this is a valid contract .. py:method:: find_schedule(contracts: Collection[negmas.situated.Contract], start: int, end: int, assume_no_further_negotiations=False, ensure_storage_for: int = 0, start_at: int = 0) Schedules a set of contracts and returns either the search_for_schedule or None if infeasible :param start: :param end: :param contracts: :param assume_no_further_negotiations: :param ensure_storage_for: :param start_at: The time at which to start scheduling. No jobs will be scheduled before this time. :returns: Schedule information (See `ScheduleInfo` for its contents).