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

SoftAllDifferent and SoftGCC incorrectly throw AssertionErrors on infeasible stores #47

Open
thomasleaute opened this issue Dec 13, 2020 · 2 comments

Comments

@thomasleaute
Copy link

The following code:

Store store = new Store ();
		
// Create the variables
IntVar cost = new IntVar (store, "cost", 0, 2);
IntVar[] vars = new IntVar [2];
vars[0] = new IntVar (store, "v_0", 0, 1);
vars[1] = new IntVar (store, "v_1", 0, 1);

// Ground the variables using In constraints, such that the store is infeasible
store.impose(new In (cost, new IntervalDomain (0, 0)));
store.impose(new In (vars[0], new IntervalDomain (0, 0)));
store.impose(new In (vars[1], new IntervalDomain (0, 0)));
		
// Impose a SoftAlldifferent constraint
store.imposeDecomposition(new SoftAlldifferent (vars, cost, ViolationMeasure.DECOMPOSITION_BASED));
		
System.out.println(store.consistency());

throws

Exception in thread "main" java.lang.AssertionError: non-optimal arcs:
[1->sink, flow=0/1  reduced=-1, index=2]
	at org.jacop.constraints.netflow.Assert.checkOptimality(Assert.java:269)
	at org.jacop.constraints.netflow.simplex.NetworkSimplex.networkSimplex(NetworkSimplex.java:368)
	at org.jacop.constraints.netflow.NetworkFlow.consistency(NetworkFlow.java:255)
	at org.jacop.core.Store.consistency(Store.java:547)

when asserts are enabled.

@thomasleaute thomasleaute changed the title SoftAllDifferent incorrectly throws AssertionErrors on infeasible stores SoftAllDifferent and SoftGCC incorrectly throw AssertionErrors on infeasible stores Dec 13, 2020
@thomasleaute
Copy link
Author

Same issue with SoftGCC:

Store store = new Store ();
		
// Create the variables
IntVar cost = new IntVar (store, "cost", 0, 2);
		
IntVar[] xVars = new IntVar[2];
xVars[0] = new IntVar (store, "x0", 0, 1);
xVars[1] = new IntVar (store, "x1", 0, 1);
		
IntVar[] hardCounters = new IntVar [2];
hardCounters[0] = new IntVar (store, "hardCounter0", 0, 2);
hardCounters[1] = new IntVar (store, "hardCounter1", 0, 2);
		
IntVar[] softCounters = new IntVar [2];
softCounters[0] = new IntVar (store, "softCounter0", 0, 2);
softCounters[1] = new IntVar (store, "softCounter1", 0, 2);
		
// Ground the variables using In constraints such that the store is infeasible
store.impose(new In (xVars[0], new IntervalDomain (0, 0)));
store.impose(new In (xVars[1], new IntervalDomain (0, 0)));
store.impose(new In (hardCounters[0], new IntervalDomain (2, 2)));
store.impose(new In (softCounters[0], new IntervalDomain (1, 1)));
store.impose(new In (softCounters[1], new IntervalDomain (2, 2)));
store.impose(new In (cost, new IntervalDomain (1, 1)));
		
// Impose a SoftGCC 
store.imposeDecomposition(new SoftGCC (xVars, hardCounters, softCounters, cost, ViolationMeasure.VALUE_BASED));
		
System.out.println(store.consistency());

throws:

Exception in thread "main" java.lang.AssertionError: non-optimal arcs:
[1->c_1, flow=0/2  reduced=-2, index=2, forward = true, companion = [offset = 0, xVar = hardCounter1}]]
	at org.jacop.constraints.netflow.Assert.checkOptimality(Assert.java:269)
	at org.jacop.constraints.netflow.simplex.NetworkSimplex.networkSimplex(NetworkSimplex.java:368)
	at org.jacop.constraints.netflow.NetworkFlow.consistency(NetworkFlow.java:255)
	at org.jacop.core.Store.consistency(Store.java:547)

@thomasleaute
Copy link
Author

Still reproducible in JaCoP 4.10.0.

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

1 participant