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

Timing issue with Malfunctions #18

Open
Ravio-li opened this issue Dec 9, 2024 · 1 comment
Open

Timing issue with Malfunctions #18

Ravio-li opened this issue Dec 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Ravio-li
Copy link

Ravio-li commented Dec 9, 2024

The context provided when a malfunction occurs has constraint rules describing actions that have already taken place and ones that require wait actions during the malfunction duration.

Screenshot 2024-12-09 194306

Action at timestep 14 in this example causes an issue. The encoding must generate this action, but the malfunction will already occur at timestep 14 and ignores all given actions.

Screenshot 2024-12-09 194701

This means primary encodings cannot solve Env's with malfunctions right now. Removing the last action from the context past actions might still cause desync issues. The train must wait at the first timestep of the malfunction, ignoring the last occured action as it did nothing in Flatland either.

Alternatively, a primary encoding can use the malfunction(ID,Duration,Timestep) fact to simulate the lost action. I will try this out next. Maybe this is better than changing the provided context.

@helloKep helloKep self-assigned this Dec 13, 2024
@helloKep helloKep added the bug Something isn't working label Dec 13, 2024
@helloKep
Copy link
Collaborator

helloKep commented Dec 13, 2024

Thanks for sharing this, @Ravio-li. It looks like it is as simple as adjusting the range of time steps being passed into the convert_formers_to_clingo function.

I've changed two lines of code in solve.py from this:

past = convert_formers_to_clingo(actions[:timestep+1])
present = convert_malfunctions_to_clingo(malfunctions, timestep)
future = convert_futures_to_clingo(actions[timestep+1:])

to this:

past = convert_formers_to_clingo(actions[:timestep])
present = convert_malfunctions_to_clingo(malfunctions, timestep)
future = convert_futures_to_clingo(actions[timestep:])

By removing the +1, in your example then the action at time step 14 would not be encoded as an enforced move. I'm not sure about whether it would be necessary to adjust the malfunction scope (in your example lines 84-87). I don't currently have test instances with malfunctions, so if you could try the new version of solve.py and let me know whether that fixes the problem, that would be great. If this is the only fix necessary, I'll be excited to close out this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants