Skip to content

Commit

Permalink
Added manualenv and fixed doris to unix formatting .also fixed 1.9.2 …
Browse files Browse the repository at this point in the history
…=> 2.2.0 for nanobind
  • Loading branch information
perara committed Oct 21, 2024
1 parent a698dd8 commit c769175
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ENV PATH="/home/$USERNAME/.venv/bin:$PATH"

# Install nanobind
RUN pip3 install --upgrade pip && \
pip3 install nanobind==1.9.2
pip3 install nanobind==2.2.0


# Install latest cmake
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
*.egg-info
out/build
4 changes: 4 additions & 0 deletions jsp/bindings/jobshop_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "job_shop_plotter.h"
#include "job_shop_algorithms.h"
#include <multidimensional_array.hpp>
#include <job_shop_manual_generator.h>

namespace nb = nanobind;

Expand Down Expand Up @@ -280,6 +281,9 @@ NB_MODULE(jobshop, m) {
.def_static("verifyOptimalSolution", &TaillardJobShopGenerator::verifyOptimalSolution)
.def_static("runAllVerifications", &TaillardJobShopGenerator::runAllVerifications);

nb::class_<ManualJobShopGenerator>(m, "ManualJobShopGenerator")
.def_static("generateFromFile", &ManualJobShopGenerator::generateFromFile);

// Bind LivePlotter class
nb::class_<LivePlotter>(m, "LivePlotter")
.def(nb::init<int>())
Expand Down
208 changes: 103 additions & 105 deletions jsp/environments/doris.csv
Original file line number Diff line number Diff line change
@@ -1,106 +1,104 @@
[METADATA]
# This section contains metadata about the job shop problem
num_jobs: 36
num_machines: 3
[METADATA END]

[JOB DEPENDENCIES]
# Only jobs with dependencies are listed
# Format: jobIndex: depJobIndex1, depJobIndex2, ...

1:0
2:10
3:10
4:10
5:10
6:10
7:4
8:4
9:12,13,14
10:0
11:10
12:11
13:11
14:11
15:19,29
16:7
17:12,13,14
18:17
19:15
20:15
21:15
22:12,13,14,18,29
23:12,13,14,22
24:9
25:9,12,13,14
26:31
27:31
28:7
29:28
30:23
31:17
32:4
33:4
34:12,13,14
35:24
[JOB DEPENDENCIES END]


[OPERATION DURATIONS]
# Each line represents a job
# The number of operations is now 1 for each job
# Job 0 has 1 operation with duration 49
# Job 1 has 1 operation with duration 64, and so on
49
64
36
12
210
24
10
0
24
0
24
48
60
0
0
48
50
48
24
0
0
0
48
5
0
10
72
36
24
20
10
70
10
10
10
10
[OPERATION DURATIONS END]

[OPERATION DEPENDENCIES]
# Only jobs with dependencies are listed
# Format remains opIndex1:depOpIndex1,depOpIndex2,...

# Job 1 (Operation 1 depends on Operation 0)
#1:1:0

# Job 3 (Operation 1 depends on Operation 0; Operation 2 depends on Operation 1)
#3:1:0;2:1

# Job 5 (Operation 1 depends on Operation 0)
#5:1:0

# Continue similarly for other jobs...
[METADATA]
num_jobs:36
num_machines:3
[METADATA END]

[JOB DEPENDENCIES]
# Only jobs with dependencies are listed
# Format: jobIndex: depJobIndex1, depJobIndex2, ...
1:0
2:10
3:10
4:10
5:10
6:10
7:4
8:4
9:12,13,14
10:0
11:10
12:11
13:11
14:11
15:19,29
16:7
17:12,13,14
18:17
19:15
20:15
21:15
22:12,13,14,18,29
23:12,13,14,22
24:9
25:9,12,13,14
26:31
27:31
28:7
29:28
30:23
31:17
32:4
33:4
34:12,13,14
35:24
[JOB DEPENDENCIES END]


[OPERATION DURATIONS]
# Each line represents a job
# The number of operations is now 1 for each job
# Job 0 has 1 operation with duration 49
# Job 1 has 1 operation with duration 64, and so on
49
64
36
12
210
24
10
0
24
0
24
48
60
0
0
48
50
48
24
0
0
0
48
5
0
10
72
36
24
20
10
70
10
10
10
10
[OPERATION DURATIONS END]

[OPERATION DEPENDENCIES]
# Only jobs with dependencies are listed
# Format remains opIndex1:depOpIndex1,depOpIndex2,...

# Job 1 (Operation 1 depends on Operation 0)
#1:1:0

# Job 3 (Operation 1 depends on Operation 0; Operation 2 depends on Operation 1)
#3:1:0;2:1

# Job 5 (Operation 1 depends on Operation 0)
#5:1:0

# Continue similarly for other jobs...
[OPERATION DEPENDENCIES END]
13 changes: 8 additions & 5 deletions jsp/examples/ppo_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ def _on_training_end(self) -> None:
def run_experiment(algorithm_name: str, taillard_instance: str, use_gui: bool, max_steps: int,
observation_space: str, reward_function: str) -> None:
def make_env() -> Callable[[], gym.Env]:
instance: jobshop.TaillardInstance = getattr(jobshop.TaillardInstance, taillard_instance)
jobs, ta_optimal = jobshop.TaillardJobShopGenerator.loadProblem(instance, True)
#instance: jobshop.TaillardInstance = getattr(jobshop.TaillardInstance, taillard_instance)
jobs, ta_optimal = jobshop.ManualJobShopGenerator.generateFromFile("/workspaces/job-shop-simulator/jsp/environments/doris.csv")
print(jobs, ta_optimal)
#jobs, ta_optimal = jobshop.TaillardJobShopGenerator.loadProblem(instance, True)
print(f"Optimal makespan for {taillard_instance}: {ta_optimal}")

obs_space = DefaultObservationSpace() if observation_space == "default" else NormalizedObservationSpace()
Expand All @@ -269,10 +271,11 @@ def make_env() -> Callable[[], gym.Env]:
print(f"Gap: {(makespan_callback.best_makespan - ta_optimal) / ta_optimal * 100:.2f}%")

if __name__ == "__main__":
print(":D")
parser: argparse.ArgumentParser = argparse.ArgumentParser(description="Run Job Shop Scheduling experiment with PPO")
parser.add_argument("algorithm", choices=["PPO"], help="Algorithm type")
parser.add_argument("taillard_instance", choices=[f"TA{i:02d}" for i in range(1, 81)], help="Taillard instance")
parser.add_argument("--no-gui", action="store_true", help="Disable GUI")
parser.add_argument("--algorithm", choices=["PPO"], default="PPO", help="Algorithm type")
parser.add_argument("--taillard_instance", default="TA01", choices=[f"TA{i:02d}" for i in range(1, 81)], help="Taillard instance")
parser.add_argument("--no-gui", action="store_false", help="Disable GUI")
parser.add_argument("--max-steps", type=int, default=1000, help="Maximum number of steps per episode")
parser.add_argument("--observation-space", choices=["default", "normalized"], default="normalized", help="Observation space type")
parser.add_argument("--reward-function", choices=["makespan", "progress"], default="progress", help="Reward function type")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel", "cmake>=3.30", "nanobind==1.9.2", "ninja"]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel", "cmake>=3.30", "nanobind==2.2.0", "ninja"]
build-backend = "setuptools.build_meta"

[project]
Expand Down

0 comments on commit c769175

Please sign in to comment.