I was trying to solve something like (A <= C) AND (B <= C) with all variable domain (-100, 100), but got java.lang.OutOfMemoryError: Java heap space
when I searching for all solutions.
Is this expected or I'm missing something?
The reason is that there is many solutions that are stored in the memory. In fact, you have 100*100*100 solutions. There are several ways to solve the problem. First, you can set the search in such a way that the solutions will not be stored; you only print them. For this you can use the following instructions, for example (assuming your DepthFirstSearch is called label).
The last line instructs search to not store solutions.
If you need all solution stored, you can extend the heap size by using -Xmx option of java command.
Sorry, you have 2,727,101 solutions ;)
I increased the heap space memory and it worked. Thanks
I am getting an error saying "java.lang.Error: java.lang.OutOfMemoryError: GC overhead limit exceeded". The no. of variables was about 32.
I don't need to store "all" the solutions. I need just 2 of them at a time. I am using BooleanVar. I want to compare which variables in my solutions change their value across the solutions (0 to 1 or 1 to 0). So in short I have to compare the current solution to the previous solution. So I was setting recordSolutions to true and storing all the solutions. This serves my purpose but consumes a lot of memory.
Is there any other way I can do this ? Thanks.
You can limit the maximum number of solutions you will get by using method setSolutionLimit() from solution listener. Below, you see a simple example of limiting number of solutions to two
label.getSolutionListener().setSolutionLimit( 2 );
Hope it helps,
Log in to post a comment.