cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

large number of inputs

payman
13-Aquamarine

large number of inputs

Hello All,

My program receives models information from an Excel file and performs the calculations and returns some results as the outputs.

when I run the program for large number of input models (300 models for example), the final result is different from individual calculation by the same program.

I have repeated this several times. The results of individual calculations are always the same, the results of large number of models are always the same but they don't match.

Is there something about Mathcad that I should consider for large number of calculation? or the problem is in the program itself?

1 ACCEPTED SOLUTION

Accepted Solutions
AndyWesterman
4-Participant
(To:payman)

on a different topic, I would recommend not calling the same subroutine, multiple times.

Capture.PNG

This will call the same subroutine 5 times,

replacing it with

Capture.PNG

will only call the subroutine once & therefore reduce the time to complete one calculation cycle.

making changes as attached has reduced the time for one calculation from ~73 seconds to ~7 seconds.

There will be more instances of this but it shows what is possible.

I don't think that this will affect the calculations that you are making but you will need to verify that this is true

Regards

Andy

PS: changing the value of i in the "for i " loop isn't best practice either so I've changed that too.

View solution in original post

6 REPLIES 6
Werner_E
24-Ruby V
(To:payman)

Hard to say without knowing what you are doing exactly. But I don't think that the number of calculation influences Mathcad's results. I rather guess its an error in the way you do the calculations or read in the data which by chance just shows in certain situations. I guess that not all calculations are wrong but just some beginning from a certain point!?

For example if you read in the data from your excel sheets and you do not initialize the matrix you read it in, ther may be values from a prior read be left because the new matrix should be smaller because you read less data.

payman
13-Aquamarine
(To:Werner_E)

Thank you Werner, as you mentioned the issue is probably from reading a large number of inputs .

what do you mean by "initialize the matrix " ? How can I remove this issue?

Werner_E
24-Ruby V
(To:payman)

PAYMAN RAJAI wrote:

Thank you Werner, as you mentioned the issue is probably from reading a large number of inputs .

No, its not the number of input files. But the more calculations you make, the greater is the probability that a (hidden) error shows up.

what do you mean by "initialize the matrix " ? How can I remove this issue?

I am in the dark, I have no idea what you are doing as you don't attach a sheet. I don't know how you read your data, which data structure you use, who you accomplish the iteration over your many Excel data sheets, etc.

If you have a 3x3 matrix M and you assign four values M[0,0 to M[1,1, it will still be a 3x3 matrix. If you set M to a scalar, e.g. M:=0, before you assign the four values, you get a 2x2 matrix.

StuartBruff
23-Emerald II
(To:Werner_E)

??? What happened to the message with the example worksheet?

Stuart

PS. Could you give an example of an individual calculation differing from a batch calculation? The worksheet (that no longer appears to be there) takes rather a long time to run, and I'm not sure whether reducing the number of models (each column is a model?) will show up the difference.

payman
13-Aquamarine
(To:StuartBruff)

Thank you Stuart,

I disabled examples in my program and the situation is better now. I checked some cases and saw no difference fortunately.

I have put my program to re do a batch calculation. I will post the program if the issue were not removed.

AndyWesterman
4-Participant
(To:payman)

on a different topic, I would recommend not calling the same subroutine, multiple times.

Capture.PNG

This will call the same subroutine 5 times,

replacing it with

Capture.PNG

will only call the subroutine once & therefore reduce the time to complete one calculation cycle.

making changes as attached has reduced the time for one calculation from ~73 seconds to ~7 seconds.

There will be more instances of this but it shows what is possible.

I don't think that this will affect the calculations that you are making but you will need to verify that this is true

Regards

Andy

PS: changing the value of i in the "for i " loop isn't best practice either so I've changed that too.

Top Tags