Skip to main content
1-Visitor
April 11, 2020
Solved

How to get trace to output all iterations

  • April 11, 2020
  • 11 replies
  • 4266 views

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 

Best answer by Werner_E

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.

 

11 replies

21-Topaz II
April 11, 2020

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

KhariH1-VisitorAuthor
1-Visitor
April 11, 2020

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. 

21-Topaz II
April 11, 2020

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

23-Emerald V
April 11, 2020
You might find the Mathcad worksheet attached to the following old post to be of some interest.

https://community.ptc.com/t5/PTC-Mathcad/Hooke-Jeeves-function-TOMS178/td-p/65033

It uses the Hooke-Jeeves method to give a result for the Rosenbrock function.

Stuart
24-Ruby IV
April 12, 2020

It is the object of the study 13 of the book

 2^5 problems for stem education