scml.scml2020.components.prediction =================================== .. py:module:: scml.scml2020.components.prediction Classes ------- .. autoapisummary:: scml.scml2020.components.prediction.TradePredictionStrategy scml.scml2020.components.prediction.ExecutionRatePredictionStrategy scml.scml2020.components.prediction.FixedTradePredictionStrategy scml.scml2020.components.prediction.MarketAwareTradePredictionStrategy scml.scml2020.components.prediction.FixedERPStrategy scml.scml2020.components.prediction.MeanERPStrategy Module Contents --------------- .. py:class:: TradePredictionStrategy(*args, predicted_outputs: Union[int, numpy.ndarray] = None, predicted_inputs: Union[int, numpy.ndarray] = None, add_trade=False, **kwargs) A prediction strategy for expected inputs and outputs at every step :param - `predicted_inputs`: None for default, a number of an n_steps numbers giving predicted inputs :param - `predicted_outputs`: None for default, a number of an n_steps numbers giving predicted outputs Provides: - `expected_inputs` : n_steps vector giving the predicted inputs at every time-step. It defaults to the number of lines. - `expected_outputs` : n_steps vector giving the predicted outputs at every time-step. It defaults to the number of lines. - `input_cost` : n_steps vector giving the predicted input cost at every time-step. It defaults to catalog price. - `output_price` : n_steps vector giving the predicted output price at every time-step. It defaults to catalog price. Hooks Into: - `init` - `before_step` - `step` Abstract: - `trade_prediction_init`: Called during init() to initialize the trade prediction. - `trade_prediction_step`: Called during step() to update the trade prediction. Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:attribute:: expected_outputs :value: None Expected output quantity every step .. py:attribute:: expected_inputs :value: None Expected input quantity every step .. py:attribute:: input_cost :type: numpy.ndarray :value: None Expected unit price of the input .. py:attribute:: output_price :type: numpy.ndarray :value: None Expected unit price of the output .. py:attribute:: _add_trade :value: False .. py:method:: trade_prediction_init() -> None :abstractmethod: Will be called to update expected_outputs, expected_inputs, input_cost, output_cost during init() .. py:method:: trade_prediction_before_step() -> None Will be called at the beginning of every step to update the prediction .. py:method:: trade_prediction_step() -> None Will be called at the end of every step to update the prediction .. py:method:: init() .. py:method:: before_step() .. py:method:: step() .. py:class:: ExecutionRatePredictionStrategy A prediction strategy for expected inputs and outputs at every step Provides: - `predict_quantity` : A method for predicting the quantity that will actually be executed from a contract Abstract: - `predict_quantity` : A method for predicting the quantity that will actually be executed from a contract Hooks Into: - `internal_state` Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:method:: predict_quantity(contract: negmas.Contract) :abstractmethod: .. py:class:: FixedTradePredictionStrategy(*args, add_trade=True, **kwargs) Bases: :py:obj:`TradePredictionStrategy` Predicts a fixed amount of trade both for the input and output products. Hooks Into: - `internal_state` - `on_contracts_finalized` Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:attribute:: _add_trade :value: True .. py:method:: trade_prediction_init() Will be called to update expected_outputs, expected_inputs, input_cost, output_cost during init() .. py:property:: internal_state .. py:method:: on_contracts_finalized(signed: List[negmas.Contract], cancelled: List[negmas.Contract], rejectors: List[List[str]]) -> None .. py:class:: MarketAwareTradePredictionStrategy(*args, predicted_outputs: Union[int, numpy.ndarray] = None, predicted_inputs: Union[int, numpy.ndarray] = None, add_trade=False, **kwargs) Bases: :py:obj:`TradePredictionStrategy` Predicts an amount based on publicly available market information. Falls back to fixed prediction if no information is available Hooks Into: - `internal_state` - `on_contracts_finalized` Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:method:: init() .. py:method:: trade_prediction_init() Will be called to update expected_outputs, expected_inputs, input_cost, output_cost during init() .. py:method:: __update() .. py:method:: trade_prediction_step() Will be called at the end of every step to update the prediction .. py:method:: trade_prediction_before_step() Will be called at the beginning of every step to update the prediction .. py:property:: internal_state .. py:class:: FixedERPStrategy(*args, execution_fraction=0.95, **kwargs) Bases: :py:obj:`ExecutionRatePredictionStrategy` Predicts that the there is a fixed execution rate that does not change for all partners :param execution_fraction: The expected fraction of any contract's quantity to be executed Provides: - `predict_quantity` : A method for predicting the quantity that will actually be executed from a contract Hooks Into: - `internal_state` Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:attribute:: _execution_fraction :value: 0.95 .. py:method:: predict_quantity(contract: negmas.Contract) .. py:class:: MeanERPStrategy(*args, execution_fraction=0.95, **kwargs) Bases: :py:obj:`ExecutionRatePredictionStrategy` Predicts the mean execution fraction for each partner :param execution_fraction: The expected fraction of any contract's quantity to be executed Provides: - `predict_quantity` : A method for predicting the quantity that will actually be executed from a contract Hooks Into: - `internal_state` - `init` - `on_contract_executed` - `on_contract_breached` Remarks: - `Attributes` section describes the attributes that can be used to construct the component (passed to its `__init__` method). - `Provides` section describes the attributes (methods, properties, data-members) made available by this component directly. Note that everything provided by the bases of this components are also available to the agent (Check the `Bases` section above for all the bases of this component). - `Requires` section describes any requirements from the agent using this component. It defines a set of methods or properties/data-members that must exist in the agent that uses this component. These requirement are usually implemented as abstract methods in the component - `Abstract` section describes abstract methods that MUST be implemented by any descendant of this component. - `Hooks Into` section describes the methods this component overrides calling `super` () which allows other components to hook into the same method (by overriding it). Usually callbacks starting with `on_` are hooked into this way. - `Overrides` section describes the methods this component overrides without calling `super` effectively disallowing any other components after it in the MRO to call this method. Usually methods that do some action (i.e. not starting with `on_`) are overridden this way. .. py:attribute:: _execution_fraction :value: 0.95 .. py:attribute:: _total_quantity :value: None .. py:method:: predict_quantity(contract: negmas.Contract) .. py:method:: init() .. py:property:: internal_state .. py:method:: on_contract_executed(contract: negmas.Contract) -> None .. py:method:: on_contract_breached(contract: negmas.Contract, breaches: List[negmas.Breach], resolution: Optional[negmas.Contract]) -> None