constraint programming - Java Choco CSP optimize using sum of variables -
i using choco solve csp. want this:
boolvar[] badrow = getbadrow(); solver.findoptimalsolution(resolutionpolicy.minimize, sum(badrow)); in other words, want system find solution badrow has fewest true values in it. don't want "constraint" because system fail, , want avoid failures. cant find way create intvar sum of other variables.
how accomplish this?
i taking wrong angle completely. instead of trying build variable sum of other variables, create plain variable , constrain sum of other variables, this:
intvar overflows = variablefactory.integer("overflows", 0, maxoverflows, solver); constraint tracker = intconstraintfactory.sum(badrow, overflows); solver.post(tracker); solver.findalloptimalsolutions(resolutionpolicy.minimize, overflows, true); and solved it. feel silly not seeing it.
Comments
Post a Comment