I have successfully optimized a function (Rosenbrock) under the constraints -5<=x<=5 and -5<=y<=5 but I want to see the values that each iteration produced and how they change in response to my initial guess value. I cannot figure out how to get the trace command to output all the iteration values, it only shows the final solution. I backtracked to MathCAD 15 to have access to the debug window but if anyone can help me in MathCAD 15 it would be very much appreciated.
Or if anyone knows how to display iterations in a solve block for constrained multivariable optimization in MathCAD Prime 5 that would also help and I've attached that version also.
Thanks
Solved! Go to Solution.
The standard algorithm used for "minimize" is "Conjugate Gradient". Looking at the trace it seems that it tries a few standard values like (0,0), (0,1) etc. but then later in the trace you see that it starts using your guess values..
You can change the algorithm to "Quasi Newton" and also set some options by right clicking on the word "minimize".
After changing the algorithm to Quasi Newton the iteration immediately starts with your guesses but strange enough when set back to Conjugate Gradient it also starts with your guesses and not with (0;0). No clue why and whats happening here.
Hi,
"I cannot figure out how to get the trace command to output all the iteration values, it only shows the final solution" - Bad news.
trace and pause only work within Mathcad 15 programming. You would need to program a minimize function to use trace and pause. Minimize is a function that works within a solve block with no ability to trace or pause.
Good news.
You can use Scilab a free math program that has the ability to trace internally within its optimize function and plot the intermediate values.
Cheers
Terry
I was able to get trace to output the iteration history for minimizing the function by following the quicksheet guide. However it didn't incorporate the constraints and ignored the value the initial guess value I assigned and instead started with (0,0) according to the history. Are you saying there's no way to have a constrained minimize function have it's history traced?
Thanks for the answer.
Hi
"I was able to get trace to output the iteration history for minimizing the function by following the quicksheet guide."
Can you post your worksheet I thought this was impossible in Mathcad.
Terry
The orange areas are the constrained problem where I disabled the calculation. The rest is where I programed trace to print out the iteration history, which is does if you backspace the solution and then hit " = " so it runs again. The trace window will show the history and I noticed it started at (0,0) even though my initial start was (5,5)
Thank you very much.
Cheers
Terry
The standard algorithm used for "minimize" is "Conjugate Gradient". Looking at the trace it seems that it tries a few standard values like (0,0), (0,1) etc. but then later in the trace you see that it starts using your guess values..
You can change the algorithm to "Quasi Newton" and also set some options by right clicking on the word "minimize".
After changing the algorithm to Quasi Newton the iteration immediately starts with your guesses but strange enough when set back to Conjugate Gradient it also starts with your guesses and not with (0;0). No clue why and whats happening here.
Wow thanks I could swear that yesterday when I was doing this, it never even touched my initial guess values I changed the method like you said and it worked. Is there anyway for me to incorporate the constraints (range of x and y) into the trace programming loop?
The constraints should be considered if you create a solve block (putting the "Given" in front).
Keep in mind that Mathcad considers the function to minimize and also the constraints you apply as kind of "soft" constraints. It tries to minimize the overall error, which means, that the constraints may not be fully complied with. You may "weight" those constraints by multiplications. x<5 has less "weight" than 10^4*x<5*10^4 or 10^4*(5-x)>0 because in the latter case a small exceedance of x means a larger absolute error.
Hi,
This is late so I trust it gets to you.
You should change the tolerance variables to get a more accurate approach to the minimum point.
In Prime :- Calculation | Worksheet Options | CTOL and TOL from the default 10-3 to 10-6
In Mathcad :- Tools | Worksheet Options | Built In Variables | CTOL and TOL.
This gets a finer approximation to the minimum of (1, 1).
Cheers
Terry