Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bugs branch #11

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions JSSEnv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from gym.envs.registration import register

register(
id='jss-v1',
entry_point='JSSEnv.envs:JssEnv',
)
id="JSSEnv-v1",
entry_point="JSSEnv.envs:JssEnv",
)
316 changes: 214 additions & 102 deletions JSSEnv/envs/JssEnv.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion JSSEnv/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from JSSEnv.envs.JssEnv import JssEnv
from JSSEnv.envs.JssEnv import JssEnv
Empty file added JSSEnv/utils.py
Empty file.
2 changes: 2 additions & 0 deletions JSSEnv/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VERSION = "1.0.2"
ENV_LIST = ["JSSEnv-v1"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Once installed, the environment will be available in your OpenAi's gym environme

```python
import gym
env = gym.make('JSSEnv:jss-v1', env_config={'instance_path': 'INSTANCE_PATH'})
env = gym.make('JSSEnv:JSSEnv-v1', env_config={'instance_path': 'INSTANCE_PATH'})
```

### Important: Your instance must follow [Taillard's specification](http://jobshop.jjvh.nl/explanation.php#taillard_def).
Expand Down
46 changes: 29 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
from setuptools import setup, find_packages
from JSSEnv.version import VERSION

setup(name='JSSEnv',
version='1.0.0',
author="Pierre Tassel",
author_email="[email protected]",
description="An optimized OpenAi gym's environment to simulate the Job-Shop Scheduling problem.",
url="https://github.com/prosysscience/JSSEnv",
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
install_requires=['gym', 'pandas', 'numpy', 'plotly', 'imageio', 'psutil', 'requests', 'kaleido', 'pytest',
'codecov'],
include_package_data=True
)
setup(
name="JSSEnv",
version=VERSION,
author="Pierre Tassel",
author_email="[email protected]",
description="An optimized OpenAi gym's environment to simulate the Job-Shop Scheduling problem.",
url="https://github.com/prosysscience/JSSEnv",
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
install_requires=[
"gym",
"pandas",
"numpy",
"plotly",
"imageio",
"psutil",
"requests",
"kaleido",
"pytest",
"codecov",
],
include_package_data=True,
)
37 changes: 28 additions & 9 deletions tests/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@


class TestRendering(unittest.TestCase):

def test_optimum_ta01_gif(self):
# http://optimizizer.com/solution.php?name=ta01&UB=1231&problemclass=ta
env = gym.make('JSSEnv:jss-v1', env_config={'instance_path': '../JSSEnv/envs/instances/ta01'})
env = gym.make(
"JSSEnv:JSSEnv-v1",
env_config={"instance_path": "../JSSEnv/envs/instances/ta01"},
)
env.reset()
self.assertEqual(env.current_time_step, 0)
# for every machine give the jobs to process in order for every machine
Expand All @@ -26,7 +28,7 @@ def test_optimum_ta01_gif(self):
[7, 9, 8, 5, 6, 0, 2, 3, 1, 13, 14, 12, 4, 10, 11],
[6, 0, 7, 11, 5, 14, 10, 2, 4, 13, 8, 9, 3, 12, 1],
[13, 10, 7, 9, 5, 3, 11, 1, 12, 14, 2, 4, 0, 6, 8],
[13, 11, 6, 8, 7, 4, 1, 5, 3, 10, 0, 14, 9, 2, 12]
[13, 11, 6, 8, 7, 4, 1, 5, 3, 10, 0, 14, 9, 2, 12],
]
done = False
job_nb = len(solution_sequence[0])
Expand All @@ -42,10 +44,18 @@ def test_optimum_ta01_gif(self):
break
if env.machine_legal[machine] and index_machine[machine] < job_nb:
action_to_do = solution_sequence[machine][index_machine[machine]]
if env.needed_machine_jobs[action_to_do] == machine and env.legal_actions[action_to_do]:
if (
env.needed_machine_jobs[action_to_do] == machine
and env.legal_actions[action_to_do]
):
no_op = False
self.assertTrue(env.legal_actions[action_to_do], "We don't perform illegal actions")
self.assertEqual(sum(env.legal_actions[:-1]), env.nb_legal_actions)
self.assertTrue(
env.legal_actions[action_to_do],
"We don't perform illegal actions",
)
self.assertEqual(
sum(env.legal_actions[:-1]), env.nb_legal_actions
)
state, reward, done, _ = env.step(action_to_do)
index_machine[machine] += 1
step_nb += 1
Expand All @@ -54,10 +64,19 @@ def test_optimum_ta01_gif(self):
if no_op and not done:
self.assertTrue(len(env.next_time_step) > 0, "step {}".format(step_nb))
previous_time_step = env.current_time_step
env._increase_time_step()
self.assertTrue(env.current_time_step > previous_time_step, "we increase the time step")
self.assertEqual(sum(index_machine), len(solution_sequence) * len(solution_sequence[0]))
env.increase_time_step()
self.assertTrue(
env.current_time_step > previous_time_step,
"we increase the time step",
)
self.assertEqual(
sum(index_machine), len(solution_sequence) * len(solution_sequence[0])
)
self.assertEqual(env.current_time_step, 1231)
imageio.mimsave("ta01.gif", images)
env.reset()
self.assertEqual(env.current_time_step, 0)


if __name__ == "__main__":
unittest.main()
Loading