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

[4.10.2] [minor] "At least one constraint is free, i.e., neither posted or reified. )." while constraint.getOpposite() is posted. #705

Closed
glelouet opened this issue Aug 17, 2020 · 4 comments
Milestone

Comments

@glelouet
Copy link
Contributor

glelouet commented Aug 17, 2020

The code that generates this is :

		Model choco = new Model();
		IntVar a = choco.intVar(1,2);
		Constraint expr = choco.arithm(a, "<", 2);
		BoolVar f = choco.boolVar(false);
		expr.reifyWith(f);
		choco.getSolver().solve();

I diged a bit, it seems to be the constraint.reifyWith(bv) call that generates this warning.

		Model choco = new Model();
		Constraint expr = choco.arithm(choco.intVar(1, 2), "<", 2);
		expr.getOpposite().post();
		choco.getSolver().solve();

IMO that can be fixed in Constraint#getStatus(), l313 :
- return mStatus;
+ return (mStatus==FREE && opposite!=null)?opposite.mStatus:mStatus;

unit/noregression test :


		Model choco = new Model();
		Constraint expr = choco.arithm(choco.intVar(1, 2), "<", 2);
		expr.getOpposite().post();
		assert expr.getStatus() == Status.POSTED;

@glelouet glelouet changed the title [4.10.2] [minor] "At least one constraint is free, i.e., neither posted or reified. )." when constrained.opposed() is posted. [4.10.2] [minor] "At least one constraint is free, i.e., neither posted or reified. )." while constrained.getOpposite() is posted. Aug 17, 2020
@glelouet glelouet changed the title [4.10.2] [minor] "At least one constraint is free, i.e., neither posted or reified. )." while constrained.getOpposite() is posted. [4.10.2] [minor] "At least one constraint is free, i.e., neither posted or reified. )." while constraint.getOpposite() is posted. Aug 17, 2020
@cprudhom
Copy link
Member

I bet this is already fixed in 4.10.3 (see 640461e)

@glelouet
Copy link
Contributor Author

glelouet commented Aug 17, 2020

That fix is bad. c.getOpposite() will always enforce the opposite is not null.
I checked if there was a test possible for c.hasOpposite() and there was none, that's why I propose to modify the getStatus() instead, which incidentally reduces the possibility of a bug for the same reasons.

@glelouet
Copy link
Contributor Author

@cprudhom please reopen. The fix is bad.

@cprudhom
Copy link
Member

My bad, your test should not thrown the message.
The getStatus() should consider the opposite too.

@cprudhom cprudhom reopened this Aug 18, 2020
@cprudhom cprudhom added this to the 4.10.4 milestone Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants