Skip to content

Commit

Permalink
Added data package into the library.
Browse files Browse the repository at this point in the history
  • Loading branch information
perara committed Nov 12, 2024
1 parent 5c040ab commit b7ed402
Show file tree
Hide file tree
Showing 93 changed files with 39 additions and 12 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
include README.md
18 changes: 18 additions & 0 deletions per_jsp/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

def get_current_directory():
from pathlib import Path
current_directory = Path(__file__).resolve().parent
return current_directory


def get_taillard_instance(instance_name):
from pathlib import Path
current_directory = get_current_directory()
instance_path = current_directory / "taillard_instances" / instance_name + ".txt"
return instance_path

def get_problem_instance(instance_name):
from pathlib import Path
current_directory = get_current_directory()
instance_path = current_directory / "problem_instances" / instance_name
return instance_path
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions per_jsp/examples/cpp/ppo_action.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations
import argparse
from typing import List, Optional, Callable
import jobshop
import per_jspp as jobshop
from per_jsp import data
import gymnasium as gym
from sb3_contrib import MaskablePPO
from stable_baselines3.common.callbacks import BaseCallback
from stable_baselines3.common.vec_env import DummyVecEnv

from jsp.jsp_env import DefaultObservationSpace, MakespanRewardFunction, JobShopGymEnv, NormalizedObservationSpace, \
from per_jsp.cpp.jsp_env import DefaultObservationSpace, MakespanRewardFunction, JobShopGymEnv, NormalizedObservationSpace, \
ProgressRewardFunction


Expand Down Expand Up @@ -70,7 +71,7 @@ def run_experiment(algorithm_name: str, taillard_instance: str, use_gui: bool, m
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.ManualJobShopGenerator.generateFromFile("/home/per/jsp/jsp/environments/doris.json")
jobs, ta_optimal = jobshop.ManualJobShopGenerator.generateFromFile(str(data.get_problem_instance("doris.json")))
print(jobs, ta_optimal)
#jobs, ta_optimal = jobshop.TaillardJobShopGenerator.loadProblem(instance, True)
print(f"Optimal makespan for {taillard_instance}: {ta_optimal}")
Expand Down
2 changes: 1 addition & 1 deletion per_jsp/examples/cpp/q_learning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import jobshop
import per_jspp as jobshop
import wandb
import argparse
from dataclasses import dataclass
Expand Down
2 changes: 1 addition & 1 deletion per_jsp/examples/cpp/random_policy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import jobshop
import per_jspp as jobshop
from dataclasses import dataclass
import wandb

Expand Down
2 changes: 1 addition & 1 deletion per_jsp/examples/cpp/sample_application_simple.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import jobshop
import per_jspp as jobshop
from tqdm import tqdm

def run_experiment(algorithm_name: str, taillard_instance: str):
Expand Down
2 changes: 1 addition & 1 deletion per_jsp/examples/cpp/sample_applicationmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from typing import List

import jobshop
import per_jspp as jobshop
from tqdm import tqdm

@dataclass
Expand Down
4 changes: 2 additions & 2 deletions per_jsp/python/per_jsp/cpp/jsp_env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Tuple, Optional
import jobshop
import per_jspp as jobshop
import numpy as np
import gymnasium as gym
from gymnasium import spaces
Expand Down Expand Up @@ -141,7 +141,7 @@ def validate_schedule(env: jobshop.JobShopEnvironment) -> Dict[str, Any]:
# Verify all scheduled operations completed
for machine_schedule in schedule:
for entry in machine_schedule:
end_time = state.jobProgress(entry.job, entry.operation)
end_time = np.asarray(state.jobProgress, copy=False)[entry.job, entry.operation]
if end_time == 0:
raise ValueError(f"Operation not completed: Job {entry.job}, Op {entry.operation}")

Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ classifiers = [
"Documentation" = "https://github.com/cair/jobshop/wiki"

[tool.setuptools]
packages = ["per_jsp", "per_jsp.algorithms", "per_jsp.cpp", "per_jsp.environment"]
package-dir = {"" = "per_jsp/python"}
packages = ["per_jsp", "per_jsp.algorithms", "per_jsp.cpp", "per_jsp.environment", "per_jsp.data"]
package-dir = { "" = "per_jsp", "per_jsp" = "per_jsp/python/per_jsp", "per_jsp.data" = "per_jsp/data" }

[tool.setuptools.package-data]
per_jsp = ["*.so", "*.pyd", "*.dylib"]
"per_jsp" = ["*.so", "*.pyd", "*.dylib"]
"per_jsp.data" = [
"problem_instances/**/*",
"taillard_instances/**/*",
"install_requirements.sh",
"parser.py"
]

[tool.pytest.ini_options]
pythonpath = ["."]
Expand Down

0 comments on commit b7ed402

Please sign in to comment.