Class SeparatorGymEnv
java.lang.Object
neqsim.process.ml.GymEnvironment
neqsim.process.ml.examples.SeparatorGymEnv
- All Implemented Interfaces:
Serializable
Gymnasium-compatible separator control environment.
This environment wraps a NeqSim separator model with a Gym-compatible API that works directly with Python RL frameworks via JPype/Py4J.
State Space (8-dimensional, continuous):
- [0] liquid_level - Liquid level fraction [0, 1]
- [1] pressure - Normalized pressure [0, 1]
- [2] temperature - Normalized temperature [0, 1]
- [3] feed_flow - Normalized feed flow [0, 1]
- [4] gas_density - Normalized gas density
- [5] liquid_density - Normalized liquid density
- [6] level_error - Setpoint tracking error [-1, 1]
- [7] valve_position - Current valve position [0, 1]
Action Space (1-dimensional, continuous):
- [0] valve_delta - Valve position change [-0.1, 0.1]
Reward:
- Negative squared level error: -10 * (level - setpoint)²
- Action penalty: -0.1 * action²
- Survival bonus: +1.0 per step
- Constraint penalty: -100 for hard constraint violation
Python Usage:
from jpype import JClass
import numpy as np
SeparatorGymEnv = JClass('neqsim.process.ml.examples.SeparatorGymEnv')
env = SeparatorGymEnv()
env.setMaxEpisodeSteps(500)
obs, info = env.reset().observation, env.reset().info
done = False
while not done:
action = policy.predict(np.array(obs))
result = env.step([float(action[0])])
obs, reward = result.observation, result.reward
done = result.terminated or result.truncated
- Version:
- 1.0
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class GymEnvironment
GymEnvironment.ResetResult, GymEnvironment.StepResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Streamprivate doubleprivate doubleprivate ThrottlingValveprivate doubleprivate doubleprivate doubleprivate doubleprivate ProcessSystemprivate Separatorprivate static final longprivate doubleFields inherited from class GymEnvironment
actionDim, actionHigh, actionLow, currentStep, envId, episodeReward, maxEpisodeSteps, observationDim, observationHigh, observationLow, rewardThreshold, terminated, truncated -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Get action names.doubleGet level setpoint.doubleGet current liquid level.private doubleprivate double[]String[]Get observation feature names.Get the underlying process system.doubleGet current valve position.private voidprivate voidprotected double[]resetInternal(Map<String, Object> options) Internal reset implementation.voidsetLevelSetpoint(double setpoint) Set level setpoint.protected GymEnvironment.StepResultstepInternal(double[] action) Internal step implementation.Methods inherited from class GymEnvironment
clipAction, getActionDim, getActionHigh, getActionLow, getCurrentStep, getEnvId, getEpisodeReward, getMaxEpisodeSteps, getObservationDim, getObservationHigh, getObservationLow, isDone, reset, reset, setMaxEpisodeSteps, setSeed, step
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
process
-
feed
-
separator
-
liquidValve
-
liquidLevel
private double liquidLevel -
valvePosition
private double valvePosition -
levelSetpoint
private double levelSetpoint -
maxPressure
private double maxPressure -
minTemp
private double minTemp -
maxTemp
private double maxTemp -
maxFeedFlow
private double maxFeedFlow
-
-
Constructor Details
-
SeparatorGymEnv
public SeparatorGymEnv()Create separator gym environment with default parameters.
-
-
Method Details
-
initializeSpaces
private void initializeSpaces() -
initializeProcess
private void initializeProcess() -
resetInternal
Description copied from class:GymEnvironmentInternal reset implementation. Override in subclass.- Specified by:
resetInternalin classGymEnvironment- Parameters:
options- reset options- Returns:
- initial observation
-
stepInternal
Description copied from class:GymEnvironmentInternal step implementation. Override in subclass.- Specified by:
stepInternalin classGymEnvironment- Parameters:
action- clipped action- Returns:
- step result
-
getObservation
private double[] getObservation() -
getLiquidOutflowRate
private double getLiquidOutflowRate() -
setLevelSetpoint
public void setLevelSetpoint(double setpoint) Set level setpoint.- Parameters:
setpoint- target level [0-1]
-
getLevelSetpoint
public double getLevelSetpoint()Get level setpoint.- Returns:
- current setpoint
-
getLiquidLevel
public double getLiquidLevel()Get current liquid level.- Returns:
- level [0-1]
-
getValvePosition
public double getValvePosition()Get current valve position.- Returns:
- position [0-1]
-
getProcess
-
getObservationNames
-
getActionNames
-