# [?] Perform optimization with a strange constraint?

Posted 4 years ago
5620 Views
|
2 Replies
|
2 Total Likes
|
 Consider the following code: Table[NMaximize[{NIntegrate[(a*(1 - 0.25*z - (1 - 0.25)*x)*x + a*(0.25*z - y + (1 - 0.25)*x)*y)/b, {a, 0, b}], z = Min[1, (x - y*0.3)/(1 - 0.3)], b*(1 - y) <= 1, 0 <= y <= x <= 1}, {x, y}], {b, 1, 1.5, 0.1}] I am trying to numerically solve an optimization problem (for x and y, for some b values). The problem has an integration in it. Interestingly, there is another variable z, which is a function of x and y, but cannot be greater than 1 (therefore I use Min function). Integration have issues because of the Min function. Any ideas?Cheers, Ovunc Answer
2 Replies
Sort By:
Posted 4 years ago
 Assuming I didn't make any stupid mistakes: NIntegrate -> Integrate, evaluate by itself first, get analytic expression replace z with Min expression in there replace last condition with y<=x, x<=1 (0<=y is covered by the one containing b for the given values) Then I end up with: In:= Table[ NMaximize[{(b x)/2 - 0.375 b x^2 + 0.375 b x y - (b y^2)/2 - 0.125 b x Min[1, 1.4285714285714286 (x - 0.3 y)] + 0.125 b y Min[1, 1.4285714285714286 (x - 0.3 y)], b*(1 - y) <= 1, y <= x, x <= 1}, {x, y}], {b, 1., 1.5, 0.1}] Out= {{0.161458, {x -> 0.645833, y -> 0.354167}}, {0.177604, {x -> 0.645833, y -> 0.354167}}, {0.19375, {x -> 0.645833, y -> 0.354167}}, {0.209896, {x -> 0.645833, y -> 0.354167}}, {0.226042, {x -> 0.645833, y -> 0.354167}}, {0.242187, {x -> 0.645833, y -> 0.354167}}} Hope this helps, Peter Answer
Posted 4 years ago
 IGNORE THE FOLLOWING - IT ACTUALLY WORKED AFTER A SMALL CHEAT:)This worked very well, thanks so much Peter! Only issue, when the problem is bigger and also the integration bounds have "z" in them - it does not run at all. oint3 = Integrate[(a*x*(1 - 0.25*z - (1 - 0.25)*x) + a*y*(0.25*z - y + (1 - 0.25)*x))/b, {a, 0, 1/(1 - y)}] + Integrate[(a*x*(1 - 0.25*z - (1 - 0.25)*x) + y*(1 - a*(1 - 0.25*z - (1 - 0.25)*x)))/b, {a, 1/(1 - y), 1/(1 - (1 - 0.25)*x - 0.25*z)}] + Integrate[x/b, {a, 1/(1 - (1 - 0.25)*x - 0.25*z), b}] Let's say we maximize the sum of three integrals with the constraints 0 <= y <= x <= 1, b*(1 - (1 - 0.25)*x - 0.25*Min[1, (x - y*0.1)/(1 - 0.1)]) >= 1}, {x, y}], {b, 1, 6, 0.1}] The same idea just cannot be used. Any ideas? I extremely appreciate your help in this. Answer