Michael Powell
unread,Jun 14, 2017, 11:30:34 AM6/14/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to or-tools...@googlegroups.com
Hello,
I am developing a variation on the Sudoku constraint model involving:
Variables: 174 (=81+81+12)
Constraints: 225 (=81+81+27 (=9+9+9) +27 (=9+9+9) +9)
Additionally, the Decision Builder is configured with ChooseRandom and
AssignRandomValue variable and value strategies.
The base Sudoku problem solver seems to run just fine, repeatably, for
the most part. Actually, not 100% repeatably, there are sometimes also
corner cases there that run indefinitely, but not as frequently as
with the variation, perhaps once every 10 or 100 times that I run the
test.
When I run my variation Problem Solver under a unit test conditions,
sometimes the solver returns with a solution fairly rapidly, within a
second or few seconds. However, other times the solver just runs and
runs and runs indefinitely, never seeming to land on a solution.
I suppose the extension I am working on could have some corner cases
that are unsolvable, but I don't think so, per se.
This doesn't seem like a solution issue to me, but instead an internal
state issue, but I could be wrong. Any insights into the inner
workings?
As far as resources are concerned, any resources I need to dispose, I
dispose, including the Problem Solver, its Solver, actually which is
disposed of within the scope of a method, not the class life time, and
any Variables or Constraints, and so on, that may require disposal as
well. The wrappers I've provided handle all this at a generic,
model-agnostic level, so if it "works" for one, I imagine it should
work for others, perhaps even all.
I am wondering whether there is some instance of Solver being left
behind in memory that might be gumming up the works. Thinking about it
a bit further, I am capturing references for things like Variables and
Constraints in the life time of the Problem Solver wrapper, not the
Solver, however, the Problem Solver life time is also limited, so
those references should be disposed of before the next Solver life
times are invoked during my unit testing. Perhaps I should be forcing
a GC garbage collection somewhere along the way as well, I don't know.
Both Problem Solver and Solver instances are utilized in a C# using
statement, which guarantees that their respective Dispose methods are
invoked.
I am working with Google.OrTools via C# .NET. Latest and greatest
versions, as far as I know.
Thanks!
Regards,
Michael Powell