scml.scml2019.common
Common data-structures and objects used throughout the SCM world implementation
Module Contents
Classes
An input/output to a production process |
|
The costs/time required for running a process on a line (with associated cancellation costs etc). This |
|
Describes a job to be run on one production line of a |
|
Describes some quantity of a product that is needed to honor a (sell) contract. |
|
A Call for proposal upon which a negotiation can start |
|
The costs/time required for running a process on a line (with associated cancellation costs etc). |
|
Gives full information about a manufacturing process that can generate or consume a product. |
|
Reports that financial standing of an agent at a given time in the simulation |
|
Read Only State of a factory |
|
Represents a factory within an SCML world. It is only accessed by the SCML2020World so it need not be made public. |
Attributes
Index of quantity in negotiation issues |
|
Index of time in negotiation issues |
|
Index of unit price in negotiation issues |
- class scml.scml2019.common.Product[source]
- __slots__ = ['id', 'production_level', 'name', 'expires_in', 'catalog_price'][source]
A product that can be transacted in.
- id: int[source]
Product index. Must be set during construction and MUST be unique for products in the same world
- class scml.scml2019.common.Process[source]
-
- inputs: List[InputOutput][source]
list of input product name + quantity required and time of consumption relative to the time required for production (value from 0 to 1)
- outputs: List[InputOutput][source]
list of output product names, quantity required and when it becomes available relative to the time required for production (value from 0 to 1)
- class scml.scml2019.common.ManufacturingProfile[source]
The costs/time required for running a process on a line (with associated cancellation costs etc). This data-structure carries full information about the
Process
es instead of just its index as inManufacturingProfileCompiled
. It is intended to be used to construct factoriesSee also
- class scml.scml2019.common.FactoryStatusUpdate[source]
-
- combine(other: FactoryStatusUpdate) None [source]
Combines this status update with another one in place
- Parameters:
other – The other status update
- Returns:
None
- classmethod combine_sets(dst: Dict[int, FactoryStatusUpdate], src: Dict[int, FactoryStatusUpdate])[source]
Combines a set of updates over time with another in place (overriding
first
) :param dst: First set of updates to be combined into :param src: second set of updates to be combined fromReturns:
- class scml.scml2019.common.RunningCommandInfo[source]
-
- profile: ManufacturingProfile[source]
The manufacturing profile associated with this command. Most importantly, it gives the process and line
- step: int[source]
The time-step relative to
beg
at the factory is currently executing theProcess
indicated inprofile
.step
will always go up by one every simulation step except if the command is paused where it does not change
- action: str[source]
The command type. For the current implementation it will always be run or none for no command
- updates: Dict[int, FactoryStatusUpdate][source]
The status updates implied by this command with their times relative to
beg
- class scml.scml2019.common.Job[source]
Describes a job to be run on one production line of a
Factory
.- line: int[source]
Index of the line on which the job is to be scheduled. Notice that it will be ignored for
run
actions.
- class scml.scml2019.common.ProductionNeed[source]
Describes some quantity of a product that is needed to honor a (sell) contract.
- class scml.scml2019.common.ProductionFailure[source]
-
- command: RunningCommandInfo[source]
Information about the command that failed
- missing_inputs: List[MissingInput][source]
The missing inputs if any with their quantities
- class scml.scml2019.common.ProductionReport[source]
-
- started: RunningCommandInfo | None[source]
Commands started
- continuing: RunningCommandInfo | None[source]
Command that is continuing
- finished: RunningCommandInfo | None[source]
Command finished
- failure: ProductionFailure | None[source]
Failures
- updates: FactoryStatusUpdate[source]
Updates applied to the factory
- class scml.scml2019.common.CFP[source]
A Call for proposal upon which a negotiation can start
- property issues[source]
Returns the set of issues associated with this CFP. Notice that some of the issues may have a single value
- penalty: float | Tuple[float, float] | List[float] | None[source]
penalty per missing item in case the seller cannot provide the required quantity. May be negotiable.
- signing_delay: int | Tuple[int, int] | List[int] | None[source]
The grace period after which the agents are asked to confirm signing the contract
- money_resolution: float | None[source]
If not None then it is the minimum unit of money (e.g. 1 for dollar, 0.01 for cent, etc)
- satisfies(query: Dict[str, Any]) bool [source]
Tests whether the CFP satisfies the conditions set by the query
- Parameters:
query – A dictionary given the conditions. See
Remarks
for details
Remarks:
The query dictionary can be used to specify any conditions that are required in the CFP. Only CFPs that satisfy ALL the conditions specified in the query are considered satisfying the query. The following keys can be set with corresponding meanings:
- is_buy
True or False. If both are OK, just do not add this key
- publisher
A string or
SCML2019Agent
specifying a specific publisher- publishers
A list of publishers (see publisher key)
- product
A string specifying a product name
- products
A list of products (see product key)
- time
A number, list or 2-items-tuple (range) specifying possible times to consider satisfactory
- unit_price
A number, list or 2-items-tuple (range) specifying possible prices to consider satisfactory
- quantity
A number, list or 2-items-tuple (range) specifying possible quantities to consider OK
- penalty
A number, list or 2-items-tuple (range) specifying possible penalties to consider satisfactory
- class scml.scml2019.common.ManufacturingProfileCompiled[source]
The costs/time required for running a process on a line (with associated cancellation costs etc).
See also
- __slots__ = ['n_steps', 'cost', 'initial_pause_cost', 'running_pause_cost', 'resumption_cost',...[source]
- classmethod from_manufacturing_profile(profile: ManufacturingProfile, process2ind: Dict[Process, int])[source]
- class scml.scml2019.common.ProductManufacturingInfo[source]
Gives full information about a manufacturing process that can generate or consume a product.
- profile: int[source]
The
ManufacturingProfile
index
- class scml.scml2019.common.FinancialReport[source]
Reports that financial standing of an agent at a given time in the simulation
- class scml.scml2019.common.FactoryState[source]
Read Only State of a factory
- line_schedules: numpy.ndarray[source]
An array of n_lines * n_steps giving the line schedules
- storage: Dict[int, int][source]
Mapping from product index to the amount available in the inventory
Amount of money hidden by the agent
Mapping from product index to the amount hidden by the agent
- profiles: List[ManufacturingProfile][source]
A list of profiles used to initialize the factory
- commands: numpy.ndarray[source]
The production command currently running
- class scml.scml2019.common.Factory[source]
Represents a factory within an SCML world. It is only accessed by the SCML2020World so it need not be made public.
- property commands: numpy.ndarray[source]
- property line_schedules: numpy.ndarray[source]
- profiles: List[ManufacturingProfile][source]
A list of profiles used to initialize the factory
- _commands: numpy.ndarray[source]
The production command currently running
- _line_schedules: numpy.ndarray[source]
- _storage: Dict[int, int][source]
Mapping from product index to the amount available in the inventory
Amount of money hidden by the agent
Mapping from product index to the amount hidden by the agent
- _jobs: Dict[Tuple[int, int], Job][source]
The jobs waiting to be run on the factory indexed by (time, line) tuples
- _carried_updates: FactoryStatusUpdate[source]
Carried updates from last executed command
- schedule(job: Job, override=False) None [source]
Schedules the given job at its
time
andline
optionally overriding whatever was already scheduled :param job: :param override:- Returns:
Success/failure
- _apply_updates(updates: FactoryStatusUpdate) None [source]
- step() List[ProductionReport] [source]
- _run(profile: ManufacturingProfile, override=True) None [source]
running is executed at the beginning of the step t
- Parameters:
profile – the profile to start giving both the line and process
override – If true, override any running processes paying cancellation cost for these processes
Remarks:
The output of a process that runs from step t to step t + n - 1 will only be in storage at step t + n
- _pause(line: int) None [source]
pausing is executed at the end of the step
- Parameters:
line – the line on which the process is running
- Returns:
The status updated for all times that need to be updated to cancel the command if it is not None. If None is returned then scheduling failed.
- Return type:
Optional[Dict[int, FactoryStatusUpdate]]
Remarks:
Not implemented yet
pausing when nothing is running is not an error and will return an empty status update
- _resume(line: int) None [source]
resumption is executed at the end of the step (starting next step count down)
- Parameters:
line – the line on which the process is running
- Returns:
The status updated for all times that need to be updated to cancel the command if it is not None. If None is returned then scheduling failed.
- Return type:
Optional[Dict[int, FactoryStatusUpdate]]
Remarks:
Not implemented yet
resuming when nothing is paused is not an error and will return an empty status update
- _stop(line: int) None [source]
stopping is executed at the beginning of the current step
- Parameters:
line – the line on which the process is running
- Returns:
The status updated for all times that need to be updated to cancel the command if it is not None. If None is returned then scheduling failed.
- Return type:
Optional[Dict[int, FactoryStatusUpdate]]
Remarks:
stopping when nothing is running is not an error and will just return an empty schedule
- _step_line(line: int) ProductionReport [source]
Steps the line to the time-step
t
assuming that it is already stepped to time-step t-1 given the storage- Parameters:
line – the line to step
- Returns:
ProductionReport