Skip to content

Commit 40124af

Browse files
committed
@ physigym hyperopt working can be launched
1 parent c249a13 commit 40124af

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

rl/sb/launch_sb_hyperopt.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
SCRIPT_PATH="rl/sb/sb_hyperopt_own.py"
4+
ALGO="tqc"
5+
NUM_INSTANCES=2
6+
NAME="${ALGO}_sb_hyperopt_own"
7+
8+
for i in $(seq 1 $NUM_INSTANCES); do
9+
# Replace 0 by 255 (unclear in your script, so removed it)
10+
nohup python "$SCRIPT_PATH" --algo "$ALGO" > "${NAME}_${i}.log" 2>&1 &
11+
echo "Instance $i launched with PID $!"
12+
sleep 10
13+
done

rl/sb/sb_hyperopt_own.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import time
1414
import physigym
1515
from gymnasium.spaces import Box
16+
from dataclasses import dataclass
1617

1718
class PhysiCellModelWrapper(gym.Wrapper):
1819
def __init__(
@@ -143,7 +144,24 @@ def _on_step(self) -> bool:
143144
raise optuna.TrialPruned()
144145

145146
return True
146-
147+
148+
149+
@dataclass
150+
class TunerConfig:
151+
algo: str = "TQC"
152+
env_id: str = "physigym/ModelPhysiCellEnv-v0"
153+
n_trials: int = 300
154+
total_timesteps: int = int(1e6)
155+
pruner_type: str = "median"
156+
start_tracking_step: int = 50000
157+
mean_elements: int = int(1e2)
158+
policy: str = "CnnPolicy"
159+
wandb_project_name: str = "IMAGE_TME_PHYSIGYM"
160+
wandb_entity: str = "corporate-manu-sureli"
161+
eval_frequency: int = int(2.5e4)
162+
observation_type: str = "image"
163+
164+
147165
class RLHyperparamTuner:
148166
def __init__(self, algo="TQC", env_id="physigym/ModelPhysiCellEnv-v0", n_trials=300, total_timesteps=int(1e6), pruner_type="median",
149167
start_tracking_step=50000, mean_elements=int(1e2), policy="CnnPolicy",
@@ -257,5 +275,12 @@ def run_optimization(self):
257275
print("✅ Best hyperparameters:", study.best_params)
258276

259277
if __name__=="__main__":
260-
rlhyperparamtuner = RLHyperparamTuner()
261-
rlhyperparamtuner.run_optimization()
278+
import tyro
279+
# Parse arguments from the command line
280+
config = tyro.cli(TunerConfig)
281+
282+
# Initialize tuner with parsed configuration
283+
tuner = RLHyperparamTuner(**config.__dict__)
284+
285+
# Run optimization
286+
tuner.run_optimization()

0 commit comments

Comments
 (0)