Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Calculation time

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-16-2013
03:00 PM

07-16-2013
03:00 PM

How can I improve the calculation time? Especially for the solve blocks.

Any files that I can read? Tips? The file * Improving Mathcad Calculation Speed *was recently removed from the site.

Thank you,

Mihai Moraru

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-18-2013
03:02 PM

07-18-2013
03:02 PM

OK, the second solve block calls a parameterized solve block. It's loop within a loop, and if one pass of the inner loop takes 0.25 seconds then that's going to be slow! If the first solve block has 6 parameters and 11 equations then it is also a minimization problem (as opposed to Find). Can you reformulate the problem to put everything in one solve block? Failing that, the only solution is to speed up the first solve block. Can you say any more about the equations in that solve block?

12 REPLIES 12

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-16-2013
04:43 PM

07-16-2013
04:43 PM

Re: Calculation time

MihaiMoraru wrote:

How can I improve the calculation time? Especially for the solve blocks.

There is no general answer to this question - it depends on a lot of factors.

If you have a concrete problem you may post the sheet and see if someone comes up with a speed up.

Any files that I can read? Tips? The file

was recently removed from the site.Improving Mathcad Calculation Speed

Usually files ond postings are not removed from this forum.

You don't state which Mathcad version you are working with, so I assume Mathcad 15.

Maybe you are talking about the quicksheet: Click "Help"/"Quicksheets"/"Mathcad Techniques"/"Improving Calculation Speed"

You may also search this forum for "calculation speed" or similar.

What we found out here a sghort time ago was that programs using stack() and augment() are much slower than programs with selfwritten routines - incomprehensible, but true.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-17-2013
01:28 AM

07-17-2013
01:28 AM

Re: Calculation time

MihaiMoraru wrote:

...The file

was recently removed from the site...Improving Mathcad Calculation Speed

"**Improving Mathcad Calculation Speed**" article from PTC Express:

http://www.imakenews.com/ptcexpress/e_article001093581.cfm?x=bcG4481,b3jsqcsB,w

http://www.imakenews.com/eletra/gow.cfm?z=ptcexpress%2C262285%2Cb3jsqcsB%2C2340181%2CbcG4481

The worksheet for MC13 can be found in attachment.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-17-2013
09:10 AM

07-17-2013
09:10 AM

Re: Calculation time

As Werner says, there's no simple answer to that question. Posting a worksheet would help a lot.

Here is one thread that expands (a lot) on what the quicksheet says about vectorization:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-17-2013
12:23 PM

07-17-2013
12:23 PM

Re: Calculation time

I would like to upload it... unfortunetly I cannot , and is not due to the 'advanced editor'.

But I can tell a bit more on the worksheet. Briefly:

- one parameterized (6 parameters) SolveBlock (11 equations)

- one objective function formed using the (partial) solution of the parameterized SolveBlock: an SSE = sum(exp(i)-calc(i))^2, i=1..7

- one SolveBlock for minimization of the SSE function (containing the 6 parameters)

So, how do I improve the calculation time when dealing particularly with SolveBlocks?

About two hours it takes to solve the optimization problem - MathcadPrime2.0.

I read the QuickSheets (Werner Exinger), the article (VladimirN.) and the thread (Richard Jackson) and is very helpful. Thank you all very much.

Mihai

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-17-2013
12:32 PM

07-17-2013
12:32 PM

Re: Calculation time

Really hard to say w/o the sheet (and probably hard with the sheet, too). Whats the problem with uploading? Technical problem (try later again; I sometimes have those probs with inserting pics in my posts) or because of proprietary confidential data in the sheet?

Don't be sure from your description if it could help (in fact I doubt it), but in Prime2 you can turn on multithreading which should speed up parallel calculations on multiprocessor machines.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-17-2013
12:49 PM

07-17-2013
12:49 PM

Re: Calculation time

I assume exp(i) means experimental. Calculate a vector of residuals rather than the SSE.

Resid(parameters):=exp(i)-calc(i)

Pass the vector of residuals to the solve block

Given

Resid(parameters)=0

Answer:=minerr(parameters)

That is faster in Mathcad 15. I've never tried it in Prime, but it may also be faster.

Having said that, with only 7 experimental values to fit it should usually converge in less than a second. Can you tell us more about the formula for calc(i)? Does it contain numeric integrals, derivatives? Does it take a long time to calculate one value? I suspect that's where the root of the problem lies.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-18-2013
12:15 PM

07-18-2013
12:15 PM

Re: Calculation time

Werner Exinger wrote:

Whats the problem with uploading? Technical problem (try later again; I sometimes have those probs with inserting pics in my posts) or because of proprietary confidential data in the sheet?

Proprietary unfortunately.

Werner Exinger wrote:

Don't be sure from your description if it could help (in fact I doubt it), but in Prime2 you can turn on multithreading which should speed up parallel calculations on multiprocessor machines.

With and without multithreading the same number of CPUs are used and the same CPUs usage %. Interesting is that the later is about 20%... I was expecting to be 80 - 90% (independent of activated or not the multithreading option). I will give it a full try.

Thank you.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-18-2013
12:43 PM

07-18-2013
12:43 PM

Re: Calculation time

Richard Jackson wrote:

I assume exp(i) means experimental. Calculate a vector of residuals rather than the SSE.

Resid(parameters):=exp(i)-calc(i)

Pass the vector of residuals to the solve block

Given

Resid(parameters)=0

Answer:=minerr(parameters)

Yes, exp(i) means experimental. I calculated a vector of residuals (using only one parameter to solve for so I can have a quick insight) and used minerr instead of Minimize. And indeed, miner is faster but it saved only 1 min (from 20 to 19).

Using the residuals or SSE makes almost no difference (0.2 min - one parameter as before) - at least in my calculations.

Richard Jackson wrote:

Can you tell us more about the formula for calc(i)? Does it contain numeric integrals, derivatives?

The equations in the first SolveBlock contains nonlinear terms, but does not contains integrals or derivatives.

Richard Jackson wrote:

Does it take a long time to calculate one value? I suspect that's where the root of the problem lies.

The solution of the first SolveBlock takes about 0.25 sec, so at least we identified the (block) root of the problem.

I tried also different initial guesses, scaled the 6 parameters in the same order of magnitude... without any improvement. I will investigate more. Thank you very much for the help.

Mihai

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-18-2013
03:02 PM

07-18-2013
03:02 PM