Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2938
| From | Eric Cousineau <eacousineau@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Curve fit for piecewise - Lazy evaluation (Defer / Hold?) on constraint passed to Minimize[]? |
| Date | 2011-06-04 10:21 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <isd0vr$1q5$1@smc.vnet.net> (permalink) |
Is there to defer / hold evaluation for a constraint passed to Minimize[]?
I'm wondering because I want to ensure that a particular point on the curve fits as closely as possible to the given data, i.e., give it more weight at that point.
Example: (sorry for some of the hackish things, coming to Mathematica from another system)
param = {x0, a, b, c, ...};
xflat = ...
yflat = ...
x0index := Position[xflat, Nearest[xflat, x0][[1]]][[1]];
y0 := yflat[[x0index]][[1]] &;
funcs = {{f[x], x < x0}, {g[x], x >= x0}};
model = Piecewise[funcs];
constraint := y0 == funcs[[1,1]] == funcs[[2,1]] /. x->x0;
(*Not sure how to do lazy*)
results = Minimize[{model, constraint}, param];
This code works without involving the y0 expression. Once that's involved, I get the error:
NMinimize::bcons: The following constraints are not valid: ... Constraints should be equalities, inequalities, or domain specifications involving the variables.
I've tried apply Defer[] and Hold[] just for kicks and giggles, but it didn't work.
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Curve fit for piecewise - Lazy evaluation (Defer / Hold?) on constraint passed to Minimize[]? Eric Cousineau <eacousineau@gmail.com> - 2011-06-04 10:21 +0000
csiph-web