Comments (4)
Hi Keng,
Thanks a lot for the compliments :)
There may be multiple ways to do it. The simplest approach IMO would be to use the callback to store the best solution found.
In CustomCallbacks:
class CustomCallbacks(DefaultCallbacks):
def __init__(self, legacy_callbacks_dict: Dict[str, callable] = None):
super(CustomCallbacks, self).__init__(legacy_callbacks_dict)
self.best_solution_makespan = float('inf')
self.best_solution = None
def on_episode_end(self, worker: "RolloutWorker", base_env: BaseEnv,
policies: Dict[PolicyID, Policy],
episode: MultiAgentEpisode, **kwargs):
env = base_env.get_unwrapped()[0]
if env.last_time_step != float('inf'):
episode.custom_metrics['make_span'] = env.last_time_step
if env.last_time_step < self.best_solution_makespan:
self.best_solution_makespan = env.last_time_step
self.best_solution = env.solution
In main, get the best solution back:
print(f'best solution makespan {config['callbacks'].best_solution_makespan}')
print(f'best solution {config['callbacks'].best_solution}')
Tell me if it solves the issue :)
from rl-job-shop-scheduling.
Assuming I've made the correct modifications in the CustomCallbacks
class, I've modified the while
loop of the original main
to be:
trainer = PPOTrainer(config=config)
while start_time + stop['time_total_s'] > time.time():
result = trainer.train()
result = wandb_tune._clean_log(result)
log, config_update = _handle_result(result)
wandb.log(log)
# wandb.config.update(config_update, allow_val_change=True)
ray.shutdown()
print(f'best solution makespan {config['callbacks'].best_solution_makespan}')
print(f'best solution {config['callbacks'].best_solution}')
It will throw: AttributeError: type object 'CustomCallbacks' has no attribute 'best_solution_makespan'
from rl-job-shop-scheduling.
I've doubled check and effectively, even when I put the variables as static for the CustomCallbacks
, it seems to be overwritten
It was a bit tricky but I finally managed to store the solution, I had to modify the environment to store the best solution as the on_episode_end
method of RLLib is not really called at the end of the episode and because of that the solution was not saved properly
The code is available in its own branch: https://github.com/prosysscience/RL-Job-Shop-Scheduling/tree/save_solution
Please give it a try and tell me if it works :)
from rl-job-shop-scheduling.
Okay, I'll let you know! I'd probably write a helper to generate the Gantt chart based on the solution generated, and create a PR :)
from rl-job-shop-scheduling.
Related Issues (20)
- An error when I try to run it HOT 7
- Save model and train on multiple instances HOT 2
- How to generate the Gantt Chart with GIFs format? HOT 1
- Python-Version? HOT 2
- About instance specifications HOT 2
- Running of Code to create GIF HOT 2
- Failed to run the code: JSSEnv not found HOT 3
- RuntimeError: Couldn't start Redis. Check log files HOT 2
- Adding variable set-up time
- where to find the solution results? HOT 5
- Makespan of ta41 cannot be achieved as mentioned in the paper HOT 4
- Specification of the solution HOT 9
- can't find environment HOT 2
- Is the code working? HOT 5
- [WinError 267] The directory name is invalid HOT 2
- Can I use debug to see the action?
- Not an Issue, just some clarification regarding inputs HOT 1
- Regarding codecov
- problem finding module tree in the code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rl-job-shop-scheduling.