ddopai


Nameddopai JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/opimwue/ddopai
SummaryA completely new version of ddop. New name to be specificed.
upload_time2024-10-24 16:29:17
maintainerNone
docs_urlNone
authorkaiguender
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ddopai


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install

``` sh
pip install ddopai
```

## What is ddopai?

To be written.

## What is the difference to Gymnasium and how to convert Gymnasium Environments?

To make any enviroment compatible with mushroomRL and other agents
defined within ddopai, there are some additional requirements when
defining the environment. Instead of inheriting from `gym.Env`, the
environment should inherit from `ddopai.envs.base.BaseEnvironment`. This
base class provides some additional necessary methods and attributes to
ensure compatibility with the agents. Below are the steps to convert a
Gym environment to a ddopai environment. We strongly recommend you to
also look at the implementation of the NewsvendorEnv
(nbs/20_environments/21_envs_inventory/20_single_period_envs.ipynb) as
an example.

#### 1. Initialization and Parameter Setup

- In the `__init__` method of your environment, ensure that any
  environment-specific parameters are added using the `set_param(...)`
  method. This guarantees the correct types and shapes for the
  parameters.
- Define the action and observation spaces using `set_action_space()`
  and `set_observation_space()` respectively. These should be called
  within the `__init__` method, rather than defining the spaces
  directly.
- In the `__init__`, and MDPInfo object needs to be created
  `mdp_info = MDPInfo(self.observation_space, self.action_space, gamma=gamma, horizon=horizon_train`)

#### 2. Handling Train, Validation, Test, and Horizon

- Implement or override the `train()`, `val()`, and `test()` methods to
  configure the correct datasets for each phase, ensuring no data
  leakage. The base class provides these methods, but you may need to
  adapt them based on your environment.
- Update the `mdp_info` to set the horizon (episode length). For
  validation and testing, the horizon corresponds to the length of the
  dataset, while for training, the horizon is determined by the
  `horizon_train` parameter. If `horizon_train` is `"use_all_data"`, the
  full dataset is used; if it’s an integer, a random subset is used.

#### 3. Step Method

- The `step()` method is handled in the base class, so instead of
  overriding it, implement a `step_(self, action)` method for the
  specific environment. This method should return a tuple:
  `(observation, reward, terminated, truncated, info)`.
- The next observation should be constructed using the
  `get_observation()` method, which must be called inside the `step_()`
  method. Make sure to correctly pass the demand (or equivalent) to the
  next step to calculate rewards.

#### 4. Pre- and Post-Processing

- Action post-processing should be done within the environment, in the
  `step()` method, to ensure the action is in the correct form for the
  environment.
- Observation pre-processing, however, is handled by the agent in
  MushroomRL. This processing takes place in the agent’s `draw_action()`
  method.

#### 5. Reset Method

- The `reset()` method must differentiate between the training,
  validation, and testing modes, and it should consider the
  `horizon_train` parameter for training.
- After setting up the mode and horizon, call `reset_index()` (with an
  integer index or `"random"`) to initialize the environment. Finally,
  use `get_observation()` to provide the initial observation to the
  agent.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opimwue/ddopai",
    "name": "ddopai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "nbdev jupyter notebook python",
    "author": "kaiguender",
    "author_email": "kai.guender@yahoo.de",
    "download_url": "https://files.pythonhosted.org/packages/1f/a6/edc764670fe26339ac976bc0724f672af084e4657d73e38468ca8928ea5a/ddopai-0.0.8.tar.gz",
    "platform": null,
    "description": "# ddopai\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` sh\npip install ddopai\n```\n\n## What is ddopai?\n\nTo be written.\n\n## What is the difference to Gymnasium and how to convert Gymnasium Environments?\n\nTo make any enviroment compatible with mushroomRL and other agents\ndefined within ddopai, there are some additional requirements when\ndefining the environment. Instead of inheriting from `gym.Env`, the\nenvironment should inherit from `ddopai.envs.base.BaseEnvironment`. This\nbase class provides some additional necessary methods and attributes to\nensure compatibility with the agents. Below are the steps to convert a\nGym environment to a ddopai environment. We strongly recommend you to\nalso look at the implementation of the NewsvendorEnv\n(nbs/20_environments/21_envs_inventory/20_single_period_envs.ipynb) as\nan example.\n\n#### 1. Initialization and Parameter Setup\n\n- In the `__init__` method of your environment, ensure that any\n  environment-specific parameters are added using the `set_param(...)`\n  method. This guarantees the correct types and shapes for the\n  parameters.\n- Define the action and observation spaces using `set_action_space()`\n  and `set_observation_space()` respectively. These should be called\n  within the `__init__` method, rather than defining the spaces\n  directly.\n- In the `__init__`, and MDPInfo object needs to be created\n  `mdp_info = MDPInfo(self.observation_space, self.action_space, gamma=gamma, horizon=horizon_train`)\n\n#### 2. Handling Train, Validation, Test, and Horizon\n\n- Implement or override the `train()`, `val()`, and `test()` methods to\n  configure the correct datasets for each phase, ensuring no data\n  leakage. The base class provides these methods, but you may need to\n  adapt them based on your environment.\n- Update the `mdp_info` to set the horizon (episode length). For\n  validation and testing, the horizon corresponds to the length of the\n  dataset, while for training, the horizon is determined by the\n  `horizon_train` parameter. If `horizon_train` is `\"use_all_data\"`, the\n  full dataset is used; if it\u2019s an integer, a random subset is used.\n\n#### 3. Step Method\n\n- The `step()` method is handled in the base class, so instead of\n  overriding it, implement a `step_(self, action)` method for the\n  specific environment. This method should return a tuple:\n  `(observation, reward, terminated, truncated, info)`.\n- The next observation should be constructed using the\n  `get_observation()` method, which must be called inside the `step_()`\n  method. Make sure to correctly pass the demand (or equivalent) to the\n  next step to calculate rewards.\n\n#### 4. Pre- and Post-Processing\n\n- Action post-processing should be done within the environment, in the\n  `step()` method, to ensure the action is in the correct form for the\n  environment.\n- Observation pre-processing, however, is handled by the agent in\n  MushroomRL. This processing takes place in the agent\u2019s `draw_action()`\n  method.\n\n#### 5. Reset Method\n\n- The `reset()` method must differentiate between the training,\n  validation, and testing modes, and it should consider the\n  `horizon_train` parameter for training.\n- After setting up the mode and horizon, call `reset_index()` (with an\n  integer index or `\"random\"`) to initialize the environment. Finally,\n  use `get_observation()` to provide the initial observation to the\n  agent.\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "A completely new version of ddop. New name to be specificed.",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/opimwue/ddopai"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b5361c75348e525e704e62003a3d678090eee09a164db7d2a6e80de493b2906",
                "md5": "dd2b66a8d28dcda69d73c93838838af5",
                "sha256": "26177c64d97fd45d3dc49640fa1ab1d4853bd407affce0dce6325d12bd273573"
            },
            "downloads": -1,
            "filename": "ddopai-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd2b66a8d28dcda69d73c93838838af5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 109636,
            "upload_time": "2024-10-24T16:29:15",
            "upload_time_iso_8601": "2024-10-24T16:29:15.569940Z",
            "url": "https://files.pythonhosted.org/packages/0b/53/61c75348e525e704e62003a3d678090eee09a164db7d2a6e80de493b2906/ddopai-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1fa6edc764670fe26339ac976bc0724f672af084e4657d73e38468ca8928ea5a",
                "md5": "cf80bc9c8c2844ed88a5f80b7e6b1495",
                "sha256": "9f7c35cc1f2e948458815f454a82ad68bf28fd81cf9e7a72250835edc67383dc"
            },
            "downloads": -1,
            "filename": "ddopai-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "cf80bc9c8c2844ed88a5f80b7e6b1495",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 94926,
            "upload_time": "2024-10-24T16:29:17",
            "upload_time_iso_8601": "2024-10-24T16:29:17.730812Z",
            "url": "https://files.pythonhosted.org/packages/1f/a6/edc764670fe26339ac976bc0724f672af084e4657d73e38468ca8928ea5a/ddopai-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-24 16:29:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opimwue",
    "github_project": "ddopai",
    "github_not_found": true,
    "lcname": "ddopai"
}
        
Elapsed time: 0.30883s