Constraint always evaluate to false for first value

75 views
Skip to first unread message

Filip Camara

unread,
Mar 1, 2013, 2:46:52 AM3/1/13
to or-tools...@googlegroups.com
Hello

Is there is any restriction for the first value allowed for a IntVar?

For example, in this code :
             IntVar[,] x = solver.MakeIntVarMatrix( nr_rows,  nr_cols,   new int[] {0,1,2},  "x");
             solver.Add(solver.MakeIsEqualCstVar(x[x,y], 0));

the x contains IntVar's which can have as possible values 0,1 and 2
When i add the constraint x[x,y]== 0 I have no solutions. If I add instead x[x,y]== 1 or x[x,y]== 2 I get the proper solution


The fix I found is to add a dummy (bogus) value in initialization of x matrix, like -2:

            IntVar[,] x = solver.MakeIntVarMatrix(nr_rows, nr_cols, new int[] {-2, 0,1,2}, "x");
            solver.Add(solver.MakeIsEqualCstVar(x[x,y], 0));

and in this case i get the desired solution. 

I tested and this behaviour is consistent for first value of a IntVar. Please can you explain if I made something wrong or it is normal behaviour ?

Thank you for your support

Laurent Perron

unread,
Mar 1, 2013, 8:20:56 AM3/1/13
to or-tools...@googlegroups.com
Hello, 

I do not understand what your code is doing.
You are writing an 'element' constraint indexed by itself ('x') ?

and what is 'y'?

Can you send me a complete example?

Thanks

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Filip Camara

unread,
Mar 1, 2013, 8:40:13 AM3/1/13
to or-tools...@googlegroups.com
I attached a working stripped example of what I try to achieve. Basically, with the code I posted, I expect to get one result with zero on all elements. But when the matrix is defined as :
IntVar[,] x = solver.MakeIntVarMatrix(2, 2, new int[] { 0, 1, 2 }, "x"); I get no solution.
When I declare matrix as :
IntVar[,] x = solver.MakeIntVarMatrix(2,2, new int[] {-2,0,1,2}, "x"); I get the desired solution
The issue I found, is that my constraint doesn't work when I test for first element of IntVar domain.

Thank you for your patience
OrTools.cs

Laurent Perron

unread,
Mar 11, 2013, 7:10:44 AM3/11/13
to or-tools-discuss
Hello, 

Are you working on the svn version, or on a particular binary distrib?

On the svn version, I have created issue22.cs and it seems to be working fine.

Thanks


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
--Laurent

Filip Camara

unread,
Mar 11, 2013, 8:04:42 AM3/11/13
to or-tools...@googlegroups.com
I just tested with the latest binary distribution Google.OrTools.NET.Windows64.2322 and it works. Previous I run also with a binary version (Runtime version : v4.0.30319 ) If you need it for debug, I can upload it here.

Thank you for your support.


On Friday, March 1, 2013 9:46:52 AM UTC+2, Filip Camara wrote:

Filip Camara

unread,
Mar 11, 2013, 8:06:13 AM3/11/13
to or-tools...@googlegroups.com
Sorry, 

Runtime version : v4.0.30319 is for net framework. The Google.OrTools.ConstraintSolver.dll version is not set (0.0.0.0).


On Friday, March 1, 2013 9:46:52 AM UTC+2, Filip Camara wrote:
Reply all
Reply to author
Forward
0 new messages