0
$\begingroup$

Say I have a function f[x,y,z], what is a good way to find its minimum or maximum value over a continuous region (e.g. a ConvexHullMesh)? Currently, I generate random points in said region and find their optimal value of f. But it's very inefficient, though the accuracy does increase with more points.

$\endgroup$
2
  • 1
    $\begingroup$ "Currently, I generate random points in said region and find their optimal value of f." - you would probably be amused to know that the "RandomSearch" setting for the Method option of NMinimize[]/NMaximize[] does exactly that, except perhaps a bit more systematically than you. $\endgroup$ Mar 14, 2018 at 17:16
  • $\begingroup$ @J.M. I am dumb, but thankful.hahua $\endgroup$
    – 2ub
    Mar 14, 2018 at 18:06

1 Answer 1

1
$\begingroup$

You can just use Minimize/Maximize. Here is a sample convex hull mesh:

SeedRandom[1];
mesh = ConvexHullMesh[RandomReal[10, {20,3}]]

enter image description here

And here is a function:

f[x_, y_, z_] := Sin[x y z] x y z

And here are the minimum/maximum of f over mesh:

Minimize[f[x, y, z], {x,y,z} ∈ mesh]
Maximize[f[x, y, z], {x,y,z} ∈ mesh]

{-237.192, {x -> 6.31328, y -> 7.5132, z -> 5.00063}}

{221.485, {x -> 7.89306, y -> 6.12804, z -> 4.57911}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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