Skip to main content

A Gymnasium environment for intelligent greenhouse control and resource optimization.

Project description

GreenOpt-AI Gym

A research-preview Python library and predefined Gymnasium environment for training and evaluating continuous-control agents against the GreenOpt-AI paper-faithful greenhouse simulator.

What is included

  • Registered environment: GreenOpt/Greenhouse-v0
  • Exact observation and nine-control action contracts
  • Fixed training-weather scaler metadata
  • Transparent multi-objective reward breakdown
  • Compatibility checks for Stable-Baselines3 TD3, DDPG and SAC agents
  • CLI tools and publication-ready metadata

The public Python wheel does not embed the trained .h5 files. The private complete release bundle supplied to the project owner includes the verified files under models/weights/. Confirm ownership and redistribution permissions before placing those model files in a public repository or release.

Installation

pip install greenopt-ai-gym

For the real predictive simulator:

pip install "greenopt-ai-gym[simulator]"

For Stable-Baselines3 training and validation:

pip install "greenopt-ai-gym[all]"

Required predictive model files

models/weights/
├── ghc_mlp_model_fs_model.h5
├── wcp_LSTM_model_fs_model.h5
└── rc_LSTM_model_fs_model.h5

Verified trained-model contract

The supplied trained models were inspected and tested as one complete inference chain without retraining or changing their weights:

Model Required input Output Role
Climate MLP (2016, 12) (2016, 17) Five-minute greenhouse-climate prediction
Crop Conv1D-LSTM (1, 2016, 16) (1, 3) Weekly stem elongation, stem thickness and cumulative trusses
Resource Conv1D-LSTM (7, 288, 10) (7, 5) Daily heating, high/low electricity, CO₂ and irrigation

The files were originally saved with Keras 2.8. The backend removes the obsolete time_major field from a temporary copy during modern-Keras loading. The original HDF5 files and learned weights remain unchanged.

Run the deep structural check with:

greenopt-ai validate-models models/weights

See MODEL_MANIFEST.json and FULL_MODEL_VALIDATION_REPORT.json for hashes, architectures and the end-to-end validation result.

Prediction-domain transparency

The predictive models use linear output layers. Consequently, a normalized prediction can occasionally fall outside the training interval [0, 1] even when model loading and feature ordering are correct. The simulator preserves raw predictions for paper fidelity and returns result["quality_flags"], identifying which outputs are extrapolations. A user interface should show those warnings and must not silently clip values used to calculate the original reward.

Create the environment

import gymnasium as gym
import greenopt_ai  # registers the environment

env = gym.make(
    "GreenOpt/Greenhouse-v0",
    model_dir=r"C:\path\to\models\weights",
    weather_path=r"C:\path\to\weather.csv",
    max_episode_weeks=23,
    reward_mode="paper_v1",
)

obs, info = env.reset(seed=42)
print({key: value.shape for key, value in obs.items()})
print(env.action_space.shape)  # (18144,) = 2016 five-minute rows × 9 controls

Train a TD3 agent

from stable_baselines3 import TD3
import gymnasium as gym
import greenopt_ai

env = gym.make(
    "GreenOpt/Greenhouse-v0",
    model_dir="models/weights",
    weather_path="weather.csv",
)

model = TD3(
    "MultiInputPolicy",
    env,
    learning_rate=1e-4,
    buffer_size=100,
    batch_size=256,
    gamma=0.99,
    verbose=1,
)
model.learn(total_timesteps=5000)
model.save("my_greenopt_td3_agent")

Inspect the scientific contract

greenopt-ai schema
greenopt-ai physical-ranges
greenopt-ai validate-models C:\path\to\models\weights
greenopt-ai validate-agent my_agent.zip --algorithm TD3

Observation dictionary

Key Shape Meaning
weather (2016, 10) Fixed-scaler normalized external weather for the next week
crop_params (1, 3) Normalized predicted crop state
resource_consumption (1, 5) Normalized previous weekly resource state
gh_climate (2016, 10) Normalized predicted greenhouse-climate state

Action space

A flat Box(0, 1, shape=(18144,)), reshaped internally to (2016, 9) in this exact control order:

  1. co2_vip
  2. int_white_vip
  3. pH_drain_PC
  4. scr_blck_vip
  5. scr_enrg_vip
  6. t_heat_vip
  7. t_ventlee_vip
  8. water_sup
  9. water_sup_intervals_vip_min

Scientific boundaries

  • Uploaded weather is transformed using the fixed training scaler; the package never refits a scaler per uploaded file.
  • Predictive models continue to exchange normalized values internally.
  • Physical-unit conversion is only for reporting and diagnostics.
  • Results are simulation outcomes within the learned-data domain, not field guarantees or autonomous deployment instructions.
  • GreenOpt-AI is a research simulation and decision-support environment. It is not a field-certified autonomous greenhouse controller.

See PUBLISHING_GUIDE.md before public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenopt_ai_gym-0.1.0.tar.gz (111.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greenopt_ai_gym-0.1.0-py3-none-any.whl (107.5 kB view details)

Uploaded Python 3

File details

Details for the file greenopt_ai_gym-0.1.0.tar.gz.

File metadata

  • Download URL: greenopt_ai_gym-0.1.0.tar.gz
  • Upload date:
  • Size: 111.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for greenopt_ai_gym-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ae52f6d8d3dc203e7e3370999275e6c461fdabb1d38a9c5ada29524d21d1020
MD5 d54a2cf8923489c00e6fab33d266aa48
BLAKE2b-256 65829a712efea16374d96f32143c71f103d8f3ab8693e41b6ba7f47272ca1219

See more details on using hashes here.

Provenance

The following attestation bundles were made for greenopt_ai_gym-0.1.0.tar.gz:

Publisher: publish.yml on ImanHindi/greenopt-ai-gym

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file greenopt_ai_gym-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: greenopt_ai_gym-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 107.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for greenopt_ai_gym-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5fb6fed6375e1c37b280f4386b3d5efa7833712c150cb2d3fe68ec7b4302ae0
MD5 274dac6f87b733c4c2509f290f9994b7
BLAKE2b-256 2bb9592331cee346b2d60b34e08de04eb7a7c4020bfb771da1388bbb51ed3bfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for greenopt_ai_gym-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ImanHindi/greenopt-ai-gym

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page