I have a set of equations. I also have a set of values and the results for the equation. Something like:
a + b + c = x
and some allocation might be:
1 + 1 + 1 = 3
2 + 3 + 4 = 9
However, the actual equations are much longer and may contain some functions, for example logarithms.
I now need to alter the result of a given set in a way that (1) the equation becomes equal to a specific value xx and (2) the parameters change as little as possible.
I thought I could solve this as a CSP by altering the eqation to
(a + ax) + (b + bx) + (c + cx) = xx
where a, b and c correspond to the old values and ax, bx and cx are the differences which need to be applied to the corresponding old values. And xx will be the result I want the equation to have. Note that a, b, c, xa, xb, cx etc. are all integer values and xx will always be within a certain distance to x, i.e. xx - d < x < xx + d
.
In a CSP a, b, c and xx would be treated as Problem facts, ax, bx, cx would be treated as Planning variable and the equation (a + ax) + (b + bx) + (c + cx) = xx
would be a hard constraint.
Minimizing all of ax, ab, ac would be a soft constraint.
I don't really see a Planning entity here.
global HardSoftScoreHolder scoreHolder;
rule "changeIsBad"
when
DeltaVariable($delta : delta)
then
scoreHolder.addSoftConstraintMatch(kcontext, -Math.abs(delta));
end
rule "equationMustBeEqual"
// No idea?
end
But I can't figure out how to go on from here. Is Optaplanner feasible for this kind of problem? It seems all PlanningVariable
s have to come from a List and have to be instances, whereas I only have integer values. Is my model correct?