Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: [mg6130] FindMin Failure on Trivial Problem
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Thomas L McKendree

Posts: 1
Registered: 12/11/04
[mg6130] FindMin Failure on Trivial Problem
Posted: Feb 22, 1997 12:54 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I'm confused as to why FindMin fails on the following problem.
I am using Mathematica 3.0, and have never used a prior version.
The problem is simply to find the point on the plane which has
the lowest weighted distance from three points. This is a vastly
oversimplified problem from what I ultimately need to solve.

The text below is my comments, added to text directly copied from
the notebook.


First, the function cost, is defined. The "X" and "Y" parameters
I am varying over are lfx and lfy. Note that cost[] does have a
real value at {lfx, lfy} = {2/3, 1}. I can plot this function,
and it is a nice, single minimum, roughly bowl-shaped function.


In:=

\!\(cost[li1x_, li1y_, li2x_, li2y_, lmx_, lmy_, lfx_, lfy_, i1_, i2_, cti1_,
cti2_, ctp_\ ]\ :=
i1\ \ cti1\ \ \@\(\((li1x - lfx)\)^2 + \((li1y - lfy)\)^2\) +
i2\ \ cti2\ \ \@\(\((li2x - lfx)\)^2 + \((li2y - lfy)\)^2\) +
ctp\ \ \@\(\((lmx - lfx)\)^2 + \((lmy - lfy)\)^2\)\n
li\_\(1 x\) = 0; li\_\(1 y\) = 2; \ li\_\(2 x\) = 0; li\_\(2 y\) = 0; \
lm\_x = 2; lm\_y = 1; \ni\_1 = 3; i\_2 = 2; ct\_i1 = 1; ct\_i2 = 2;
ct\_p = 7/2; \n
cost[li\_\(1 x\), li\_\(1 y\), \ li\_\(2 x\), li\_\(2 y\), lm\_x,
lm\_y, 2/3, 1, i\_1, i\_2, ct\_i1, ct\_i2, ct\_p]\n
Plot3D[cost[li\_\(1 x\), li\_\(1 y\), \ li\_\(2 x\), li\_\(2 y\),
lm\_x, lm\_y, lfx, lfy, i\_1, i\_2, ct\_i1, ct\_i2, ct\_p], {lfx,
\(-4\), \ 4}, {lfy, \ \(-4\), 4}]\)

General::"spell1":
"Possible spelling error: new symbol name \"\!\(li1y\)\" is similar to \
existing symbol \"\!\(li1x\)\"."

General::"spell1":
"Possible spelling error: new symbol name \"\!\(li2y\)\" is similar to \
existing symbol \"\!\(li2x\)\"."


Out[2]:=

\!\(14\/3 + \(7\ \@13\)\/3\)

Out:=

\[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator]



The real value that cost assumes when {lfx, lfy} = {2/3, 1}
is roughly 13.0796



In:=

N[Out[2]]

Out:=

13.0796




But, when I try to apply FindMinimum, Mathematica chokes,
claiming that {lfx, lfy} = {2/3, 1} gives a non-real answer,
as shown below.



In:=

\!\(FindMinimum[
cost[{li\_\(1 x\), li\_\(1 y\), li\_\(2 x\), li\_\(2 y\), lm\_x,
lm\_y, xx, yy, i\_1, i\_2, ct\_i1, ct\_i2, ct\_p}], {
xx, {2/3, 3/4}}, {yy, {1, 1.1}}]\)


FindMinimum::"fmnum":
"Objective function \!\(cost[\({0, 2.`, 0, 0, 2.`, 1.`, \
\(\\[LeftSkeleton] 21 \\[RightSkeleton]\), 1.`, 3.`, 2.`, 1.`, 2.`, \
3.5`}\)]\) is not real at \!\({xx, yy}\) = \!\({0.666666666666666607`, \
1.`}\)."


Out:=

\!\(\*
RowBox[{"FindMinimum", "[",
RowBox[{
\(cost[{li\_\(1\ x\), li\_\(1\ y\), li\_\(2\ x\), li\_\(2\ y\), lm\_x,
lm\_y, xx, yy, i\_1, i\_2, ct\_i1, ct\_i2, ct\_p}]\), ",",
\({xx, {2\/3, 3\/4}}\), ",",
RowBox[{"{",
RowBox[{"yy", ",",
RowBox[{"{",
RowBox[{"1", ",",
StyleBox["1.10000000000000008`",
StyleBoxAutoDelete->True,
PrintPrecision->2]}], "}"}]}], "}"}]}], "]"}]\)






Another approach is to provide only one starting value for each of
lfx, lfy, which is actually how I started. This, unfortunately,
gives the error message "Could not symbolically find the gradient....
Try giving two starting values for each variable."




\!\(FindMinimum[
cost[{li\_\(1 x\), li\_\(1 y\), li\_\(2 x\), li\_\(2 y\), lm\_x,
lm\_y, xx, yy, i\_1, i\_2, ct\_i1, ct\_i2, ct\_p}], {xx, 2/3}, {yy,
1}]\)

but that gives

\!\(FindMinimum::"fmgs" \( : \ \)
"Could not symbolically find the gradient of \!\(cost[\({li\_\(1\\ x\), \
li\_\(1\\ y\), li\_\(2\\ x\), li\_\(2\\ y\), lm\_x, \(\\[LeftSkeleton] 3 \
\\[RightSkeleton]\), i\_1, i\_2, ct\_i1, ct\_i2, ct\_p}\)]\). Try giving two \
starting values for each variable."\)






Any thoughts on what's going wrong, and how to fix it, would be greatly
appreciated. If Mathematica can't even do this, then I have grave doubts
that it really will be able to help me much.


Thank you,


Tom McKendree
(reachable at tmckendree@msmail3.hac.com)





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.