Skip to content

RealInterval Why Algo is wrong

Serge Stinckwich edited this page Jun 26, 2018 · 1 revision

Consider the simple problem of finding an x with these constraints:
     x ≥ 5
     x ≤ 4
Obviously there are no solutions. We can use eg ConstraintRefinement, let's check for a result in [3,5]:

c1:=(Constraint block:[:x|x first]) max:4; yourself.
c2:=(Constraint block:[:x|x first]) min:5; yourself.
box:=IntervalBox with:(3 hull:5).
cr:= ConstraintRefinement 
	constraints: (OrderedCollection with: c1 with: c2) 
	box: box."-->a ConstraintRefinement(
		box: an IntervalBox([3,5]) 
		constraints: a ConstraintsCollection(
			a Constraint([ :x | x first ] <= 4) 
			a Constraint(5 <= [ :x | x first ])))" 
cr evaluate."-->an OrderedCollection(an IntervalBox([empty]))"

Well ok, as one would expect. On the other hand, if we check the individual constraints, we of course get this:

c2 isPerhapsAdmissibleValue:box.  "-->true" "the solution would be 5"
c1 isPerhapsAdmissibleValue:box.  "-->true" "the solution would be [3,4]"

And of course for a ConstraintsCollection we also get this:

(ConstraintsCollection newFrom: { c1.c2 }) isPerhapsAdmissibleValue: box. "-->true" 
						"although there is no solution here,
							false would be preferable"

In other words from one run through the Constraints we don't know that there is no solution in [3,5]! But ConstraintsMinimizer1>>evaluateIteration assumes in this case that there is at least one solution and wrongly calcs a new min. I did this because this min calculation makes the algo rather efficient, if this assumption is correct (and it often is correct, but - well - not always), but of course it can then happen that the algo returns an empty result although a non-empty result is possible. My excuse for this coding lapsus is that i wanted to have a simple algo, that is easy to understand, and that at the same time is not too slow <stupid grin>. By the way in this simple example we could intersect 5 and [3,4] and then we could see that the solution is [empty], but this is not a general solution (and not only because IntervalBox>>intersection: is not yet implemented)!

Back to Examples