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

Encode declared constraints and print on demand the violated ones #6

Open
alxhotel opened this issue Apr 29, 2019 · 4 comments
Open

Comments

@alxhotel
Copy link

Is there a way to check if a particular constraint has been added to the problem manager before calling nextSolution?

For example, check if the constraints var == 1 has been added.

@pothitos
Copy link
Owner

pothitos commented May 1, 2019

Good morning, Alex, and thank you for the question!

If we want to add a constraint, we use e.g. pm.add(var == 1). But, unfortunately, there isn't a similar pm.check_if_added(var == 1) call.

Right now, the only way to check this is some sort of workarounds. In your example you could just check if var.min() == 1 && var.max() == 1 for example.

I don't know if your case is more complicated.

@alxhotel
Copy link
Author

alxhotel commented May 1, 2019

Hi Nikolaos, thanks for the answer. I'm trying to add new constraints based on the currently added.

Right now, the only way to check this is some sort of workarounds. In your example you could just check if var.min() == 1 && var.max() == 1 for example.

But you can only do that after running nextSolution, right?

My current workaround is just using another structure to save the current constraints.

By the way, (totally unrelated) is there a way to get the constraints that are giving a conflict (when a solution is not found)? In my program I need to output why a solution was not found, so having the conflicting constraints could help.

@pothitos
Copy link
Owner

pothitos commented May 4, 2019

Buenos días, Alex!

The check about the bounds of var can be done even before calling nextSolutioon. Because, when you declare a contraint, a first naive consistency level is immediately applied to the domain of var. Anyway, your solution is much more better.

Regarding reporting the violated constraint, there's some significant work in the bibliography I'm not aware of. I guess that just printing the last inspected constraint (before a domain wipeout) isn't a complete solution.

Anyway, I'll keep this issue open in case somebody wants to implement it.

@pothitos pothitos changed the title Search for a constraint Encode declared constraints and print on demand the violated ones May 4, 2019
@alxhotel
Copy link
Author

alxhotel commented May 6, 2019

Thanks, Nikolaos.

Great, I'll keep an eye on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants