-
-
Notifications
You must be signed in to change notification settings - Fork 39
RealInterval TestFunctions
minimize:
f(x) = log( 1 + x12 ) -
x2
constraints:
( 1 + x12 )2 + x22 = 4
-4 ≤ (x1, x2) ≤ 4
the global minimum is at f(x) = -1.732050808. Found at http://icwww.epfl.ch/~sam/Coconut-benchs/Transcendental/hock7.mod .
f:=[:x|((x at:1)squared + 1)log - (x at:2)].
f1:=[:x|((x at:1)squared + 1)squared + (x at:2)squared].
c1:=Constraint block: f1.
c1 equalToNumber: 4.
i:= -4 hull:4.
box :=IntervalBox with: i with:i.
a:=ConstraintsMinimizer1 function: f box: box constraints: c1.
a desiredPrecision: 1e-8.
a maximumIterations: 100000.
[a evaluate]timeToRun. "-->0:00:01:04.202"
a precision."-->8.944914808850513e-9" "desiredPrecision reached"
a result. "-->an Array(an IntervalBox([-0.00011847893840449902,0.00011847893840449902] [1.7320507994648202,1.732050808409735]) [-1.732050808409735,-1.732050793368516])"
a iterations."-->92561"
r:=a result first midPoint ."-->#(0.0 1.7320508039372777)"
(f value:r) equalsTo: -1.732050808. "-->true"
f value:r."-->-1.7320508039372777"
f1 value:r."-->3.9999999874197703"
Unfortunately the xi values for the minimum aren't stated, hence I could not check how good the results here really are, but they are obviously ok.
From http://icwww.epfl.ch/~sam/Coconut-benchs/Linear/supersim.mod :
minimize:
f(x,y) =x
constraints:
x + 2 y = 2
y + 2 x = 2
0 ≤ (x, y) ≤ 1
A trick-test, the constraints have only the solution f(2/3,2/3).
f:=[:x|x at:1].
f1:=[:x|(x at:1) + ((x at:2)*2)].
f2:=[:x|(x at:2) + ((x at:1)*2)].
c1:=Constraint block: f1.
c1 equalToNumber: 2.
c2:=Constraint block: f2.
c2 equalToNumber: 2.
box:=IntervalBox with: (RealInterval inf:0 sup: 1) with: (RealInterval inf:0 sup: 1).
a:=ConstraintsMinimizer1 function: f box: box constraints: {c1.c2}.
[a evaluate]timeToRun."-->0:00:00:00.418"
r:=a result."-->an Array(an IntervalBox([0.6666666666666663,0.6666666666666665] an IntervalUnion([0.6666666666666667,0.6666666666666671])) [0.6666666666666663,0.6666666666666665])"
mp:=r first midPoint. "-->#(0.6666666666666664 0.666666666666667)"
(f value:r) equalsTo: (2/3). "-->true"
a simple quadratic problem.
minimize:
f(x,y) =(1 - x)2
constraints:
10 (y - x2) = 0
-2 ≤ (x, y) ≤ 2
the minimum is at f(1,1)=0.
f:=[:x|(1 - x first)squared].
f1:=[:x|((x at:2)- (x at:1)squared)*10].
c1:=Constraint block: f1.
c1 equalToNumber: 0.
box:=IntervalBox with: (RealInterval inf: -2 sup: 2) with: (RealInterval inf: -2 sup: 2).
a:=ConstraintsMinimizer1 function: f box: box constraints: c1.
[a evaluate]timeToRun.
"0:00:00:06.853"
r:=a result.
"an Array(an IntervalBox([0.9999999999999999,1.0000000000000002] [0.9999999999999997,1.0000000000000007]) [0,4.930380657631324e-32])"
mp:=r first midPoint.
"#(1.0 1.0000000000000002)"
(f value:mp) equalsTo: 0. "true"
At http://icwww.epfl.ch/~sam/Coconut-benchs/Trigonometric/h77.mod there is this problem:
minimize:
f(x) =2 x1 (x1 - x2 - 1) + 1 + x22 + (x3 - 1)2 + (x4 - 1)4 + (x5 - 1)6
constraints:
x12 * x4 + sin(x4 - x5) = 23/2
x2 + x34 * x42 = 8 + 21/2
0 ≤ xi ≤ 4
The minimum is at f(x) = 0.2415051288.
The program at the mentioned link couldn't find a solution because it couldn't find a feasable point. Exactly the same problem had ConstraintsMinimizer1, which I crosschecked with ConstraintRefinement. Nevertheless, this is the code:
f:=[:x|2 * x first *(x first - x second -1) + 1 + x second squared + (x third -1)squared + ((x fourth -1)raisedToInteger: 4) + ((x fifth -1)raisedToInteger: 6)].
f1:=[:x|((x at:4)* (x at:1)squared)+(x fourth -x fifth)sin].
c1:=Constraint block: f1.
c1 equalToNumber: (2 raisedTo: (3/2)).
f2:=[:x|((x at:4)squared * ((x at:3)raisedToInteger:4))+ x second].
c2:=Constraint block: f1.
c2 equalToNumber: 8 + 2sqrt.
a:=(RealInterval inf: 0 sup: 4).
box:=IntervalBox with: a with: a with: a with: a with: a.
f1 value: box.
a:=ConstraintsMinimizer1 function: f box: box constraints: {c1.c2}.
a evaluate."-->an Array([empty] [empty])"
a:=ConstraintRefinement constraints: {c1.c2} box:box.
a evaluate. "an OrderedCollection()"
I did not really look into the problem, but the reason could also be my already explained wrong implementation of the algo.
At the same place http://icwww.epfl.ch/~sam/Coconut-benchs/Transcendental/alsotame.mod I found this:
minimize:
f(x,y) =exp(x - 2 * y)
constraint:
sin(-x + y - 1) = 0
with:
-2 ≤ x ≤ 2
-1.5 ≤ y ≤ 1.5
The minimum is at f(x) = 0.08208499862. This has also a sin() constraint.
f:=[:x|(x first - (2 *x second))exp].
f1:=[:x|((x at:2) - (x at:1)-1)sin].
c1:=Constraint block: f1.
c1 equalToNumber: 0.
a:=(RealInterval inf: -2 sup: 2).
b:=(RealInterval inf: -1.5 sup: 1.5).
box:=IntervalBox with: a with: b.
a:=ConstraintsMinimizer1 function: f box: box constraints: c1.
[r:=a evaluate]timeToRun ."-->0:00:00:09.379"
r."-->an Array(an IntervalBox(an IntervalUnion([0.49999999999999917,0.5000000000000001]) [1.4999999999999993,1.5]) [0.08208499862389876,0.08208499862389886])"
r:= r first midPoint ."-->#(0.49999999999999967 1.4999999999999996)"
f value: r."-->0.08208499862389884"
That is probably ok.
Obviously this algo can't solve every problem it should be able to solve. On the other hand it is not completely incapable to solve some simple problems. I'd say as a first rough idea for a constrained minimization algo it seems to be acceptable.
Back to Examples