1
$\begingroup$

I have a function with a large number of variables that I am trying to minimize subject to some constraints, but for simplicity let us say that it only has two variables, f[x, y]. The constraint is that another function, g[z], must be positive in the interval given by x and y (in my problem I usually have around 200 variables, and it needs to be monotonical in the interval between the minimum and the maximum)

Edit: Following the comment by Daniel Huber, let's define

f[x_, y_] := x^3 + 2 x y + 3
g[z_] := z^2 - 2 z 

where f is to be minimized in the region {x, y} [Element] Rectangle[{0, 0}, {4, 4}] subject to g[z] >= 0 for all z in the region Interval[{Min[x_solution, y_solution], Max[x_solution, y_solution]}]

If we did not have this constraint we would find that

Minimize[{f[x, y], constraint}, {x, y}]\[Element] Rectangle[{0, 0}, {4, 4}]
(* {3, {x -> 0, y -> 2}} *)

But g[z] < 0 for z ∈ Interval[{0, 2}]

Instead, the solution that I am looking for would be {19, {x -> 2, y -> 2}}

In my problem, the coefficients in the polynomial of g[z] are part of the variables that I am trying to optimize, while the rest of the variables are what defines the interval in which I want this polynomial to be positive (so I will take the minimum and maximum of these variables when defining the interval, similar to taking the minimum and maximum of x and y in this toy model), and it is not easy to find workarounds like studying the behavior of g[z] before optimizing f[x,y].

Additionally, my function involves a lot of terms and Minimize cannot solve it, so I would prefer solutions involving FindMinimum instead.

I hope the question is clearer now!

$\endgroup$
2
  • 1
    $\begingroup$ Please post a simple example about f and g. $\endgroup$
    – cvgmt
    May 24 at 12:20
  • $\begingroup$ You could define a condition function: c[x_, y_] = If[x < y, x < 2, y < 2] and use it as a condition. $\endgroup$ May 25 at 8:11

1 Answer 1

3
$\begingroup$

I hope I understood your question correctly. I assume that by "monotonically increasing" you mean increasing in the x and y direction. Here is an example.

With two example functions:

f[x_, y_] = 0.4 Sin[x y] ;
g[x_, y_] = (x - 1)^2 (y - 1)^2;

Without the condition on g:

sol = Minimize[{f[x, y]}, {x, y} \[Element] Rectangle[{0, 0}, {4, 4}]]
Show[
 Plot3D[f[x, y], {x, y} \[Element] Rectangle[{0, 0}, {4, 4}]],
 Graphics3D[{Green, PointSize[0.03], 
   Point[{x, y, sol[[1]]} /. sol[[2]]]}]]

enter image description here

The minimum is at: {x -> 3.40016, y -> 2.30988}

However, with the condition on g:

sol = Minimize[{f[x, y], D[g[x, y], x] > 0, 
   D[g[x, y], y] > 0}, {x, y} \[Element] Rectangle[{0, 0}, {3, 3}]]
Show[
 Plot3D[{f[x, y], g[x, y]}, {x, y} \[Element] 
   Rectangle[{0, 0}, {4, 4}], PlotStyle -> Opacity[0.5]],
 Graphics3D[{Green, PointSize[0.03], 
   Point[{x, y, sol[[1]]} /. sol[[2]]]}]]

enter image description here

The minimum is now at: {x -> 2.61006, y -> 1.80547}

$\endgroup$
1
  • $\begingroup$ Thanks for your answer! It is not what I mean, but it has helped me think of functions to use as an example, please see the edited question $\endgroup$
    – edmateosg
    May 24 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.