Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6192 > unrolled thread
| Started by | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| First post | 2011-11-05 09:47 +0000 |
| Last post | 2011-11-05 09:47 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Constraint evaluation in NMinimize Daniel Lichtblau <danl@wolfram.com> - 2011-11-05 09:47 +0000
| From | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| Date | 2011-11-05 09:47 +0000 |
| Subject | Re: Constraint evaluation in NMinimize |
| Message-ID | <j930n8$a52$1@smc.vnet.net> |
On 11/04/2011 06:02 AM, Ray Koopman wrote:
> I want to minimize f[x] with respect to x, subject to g[x].
> Both f and g depend in part on h[x], so to avoid calculating h[x]
> twice I use an auxiliary variable:
>
> NMinimize[{t = h[x]; f[x,t], g[x,t]}, {x}].
>
> That appears to work, but it depends on the constraint never being
> evaluated without first evaluating the minimand, and I can't find
> anything in the documentation that says that that will always be
> the case. Can anyone help?
>
> (I asked a similar question several years ago, at which time DrBob
> pointed me to sec 2.6.4 in the book, but it's not obvious to me if
> the standard evaluation procedure necessarily applies here.)
>
Could memoize h[x] for numeric x. That way you don't need to second
guess the evaluation internals of NMinimize.
h[x_?NumericQ] := h[x] = ...
I have some familiarity with those and offhand I've no idea if your
method above is guaranteed to work.
For purposes of speed it might also be useful to memoize f and g. Some
methods in NMinimize, such as DifferentialEvolution, may recompute at
the same points quite often.
An alternative might be:
objandconstraint[x_?NumericQ] := Module[{t}, t=h[x]; {f[x,t],g[x,t]}]
(This could also be memoized.)
Then do:
NMinimize[objandconstraint[x], {x}]
Caveat: I have not tried this (short on time at the moment) and make no
guarantee as to whether it will work. It might be DOA.
Daniel Lichtblau
Wolfram Research
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web