I am currently working through all of the unit issues. The sheet did indeed work in 15, although I admit I did make some changes to that particular formula after the conversion, which I changed back. Still no luck unfortunately, Although I am past the mpl%_exception error for now (Thanks Richard).
Re: Unknown Error: mpl%_exception - What does this mean?
Re: Unknown Error: mpl%_exception - What does this mean?
It's impossible that the sheet should have worked OK in Mathcad 15!
I suspect the unit mismatches are due to an incorrect implementation of the labels used in Prime during the worksheet conversion. For example, if you look at the last line of the Morphologic Time Loop program some of the variables have units removed by the normal division operator, and some by the inline division operator. When the inline division operator is used the units are not labeled as units. I didn't look through the entire worksheet (way too long!) but I wonder if there are not similar problems higher up the sheet.
As an aside, Prime allows vectors with mixed units, so the step of removing the units from all the return values could be dispensed with. It's probably better to get it working first with the minimum of changes though, and then go back and modify it to take advantage of one of the benefits Prime does have over MC15.
Re: Unknown Error: mpl%_exception - What does this mean?
I suspect the unit mismatches are due to an incorrect implementation of the labels used in Prime during the worksheet conversion. For example, if you look at the last line of the Morphologic Time Loop program some of the variables have units removed by the normal division operator, and some by the inline division operator. When the inline division operator is used the units are not labeled as units.
The error with U1() seems not to be due to units but you are right, that will not be the only error. I didn't scroll far enough to the right to spot that labelling discrepancy. Its not an easy to debug worksheet, indeed.
Re: Error in PDEsolve function with system of PDE's
Did you try to split the task into two parts, as Andy suggested?
Think he was somly demonstrating that the solve block works if the boundary conditions really reflect the boundaries and not the middle.
Re: Using the same WRITEEXCEL for the multiple variables
You are welcome.
Here is a way to do it using the Excel comopnent. I'm anit happy with it but you have to decide yourself what fits better your needs.
Re: Error in PDEsolve function with system of PDE's
Don't know if the attached helps. It's an old file that I've modified to incorporate some of your data.
Alan
Re: How to call values from a table and then do the minerr() calculation?
Hi:
25TTs/ 200 elements tooks me 3hrs (two time of 25TTs/ 100 elements).
25TTs/ 1500 elements tooks me about 2days.
And I think it also depends on the complication of the object.
I ran a simpler complication object and 25TTs/ 200 elements tooks me just 5-10mins.
I am not sure whether the reason is because it reaches the TOL/CTOL value.
The calculation time has no big difference when I setup TOL/CTOL from 1E-2 to 1E-5.
Re: How to call values from a table and then do the minerr() calculation?
25TTs/ 1500 elements tooks me about 2days.
And was the result satisfactory?
And I think it also depends on the complication of the object.
Sure, thats the reason a simplification/speed up of the calculation, which is done in every step of the iteration (in your case the Make_Theory() routine) would greatly influence overall calculation time.
Re: Using the same WRITEEXCEL for the multiple variables
For completeness sake I added is a self written routine WriteExcel() for Prime which can write to any position in the sheet, not just beginning at A1. Similar to WRITEEXCEL in Mathcad 15 and below. Don't understand why they removed and changed that feature in Prime.
Limitation of my routine is that it will only write to the first sheet of the Excel file - you cannot specify the full range including sheet name but only the starting cell in the first sheet.
I guess the routine will be rather slow on big Excel tables, as it would read the whole Excel sheet in a MC matrix, adds the data there and then write back that matrix.
As the task was done in Mathcad alone its a bit lengthy routine and still may contain errors - feel free to report them here.
Re: Unknown Error: mpl%_exception - What does this mean?
The error with U1() seems not to be due to units but you are right, that will not be the only error.
Correction: The U1() error sure is due to units. What I had in mind was that these unit errors in that routine are not due to wrong (automatic) labelling.
Re: How to call values from a table and then do the minerr() calculation?
Hi:
My original hoping is that minerr() can easily give a close answer without any additional setting.
Now it seems like constriants are required.
Maybe it is like the GPS. To find a shortest distance route, more clues are needed.
I have played with different built-in algorithms/options in MathCad but only LMA can give me a better approach.
However, not like other algorithms, LMA has no options to play.
Now I observe that the calculated TTs are close to setup constraints (I setup max/min values and relationship between TTs. EX: TT1<0.9*TT2, 1<TT3<2......).
Are they right ways to setup constraints?
Is there any parameter to determine how close will be between calculated TTs/constraints?
Re: How to call values from a table and then do the minerr() calculation?
My original hoping is that minerr() can easily give a close answer without any additional setting.
Now it seems like constriants are required.
Or a slight rework of the model?
However, not like other algorithms, LMA has no options to play.
Yes, thats true. But thats inherent to this algorithm.
Now I observe that the calculated TTs are close to setup constraints (I setup max/min values and relationship between TTs. EX: TT1<0.9*TT2, 1<TT3<2......).
Are they right ways to setup constraints?
Sems so, if its that what you need/want. And Richard had shown a way how to weight those constraints, if that seems necessary.
Is there any parameter to determine how close will be between calculated TTs/constraints?
You mean something else besides ERR? Nothing I would know of. But you may setup your own function to compare the fits. You would have to determine how to weight a miss from your constraints.
Just being curious - did you compare the version V2 and V3 of make_Theory and was there a significant difference?
Afterthought: It seems to be from your reports that a change of TT values changes the vector Theory a lot and maybe thats the reason the solution is so close (too close?) to the guess values you start with. Or we have a very slow convergence and minErr stops toop soon as of a limit of iteration steps you mentioned. In tha latter case it could make sense giving minimize a try, I guess.
Re: How to call values from a table and then do the minerr() calculation?
Hi:
What do you mean by "slight rework of the model"?
Are you talk about the code structure or writing the "miner() function" by myself?
About this part: I am not talking about ERR. I know minerr() is looking for TTs with min ERR and default TOL/CTOL=0.001.
"You mean something else besides ERR? Nothing I would know of. But you may setup your own function to compare the fits. You would have to determine how to weight a miss from your constraints."
My meaning is: Now my observation is that calculated TTs are close to my constraints.
Is there any way to know how far calculated TTs can be different from my constraints (my meaning is each calculated TT)?
For example: If I define TT1<0.9*TT2, what will be the ratio range of TT1/TT2? 0.7 to 0.9?
Re: How to call values from a table and then do the minerr() calculation?
Think you made your reply before I edited my post abd added the question abot V2 vs V3 and the suggestion of using minimize().
ERR will take into consideration the additional constraints, too. Its not only the length of the difference vector of measure and Theory. You may see this if in my template "MinErrTest"you add T[1<T[2 as constraint (which does not make much sense and will end up in a much bader fit). But you can observe that the value of ERR now is different from the vector length calculated below. Another way to wrire that constraint is T[2-T[1>0. If you chose 1000*(T[2-T[1)>0 you weight this constraint stronger - watch the values of T's and ERR.
What I meant with looking at the model was looking at the rather complicated way you get from TT to Theory. The way you showed it so far requires taking values from the same sheet the measured data is coming from, so it looks its not pure theory - but maybe I'm wrong.
As you last questions. Not sure what you mean with "any way to know how far calculated TTs are different from constraint". When the iteration stops you see it anyway!? And what value would you expect if you demand TT1<0.9*TT2 and you get TT1=10 and TT2=9.1 and which if TT2=0.2?
TT1<0.9*TT2 would mean that the ratio TT1/TT2 is in the range from -infinity to 0.9.
If yount want the ration between 0.7 and 0.9 you would write 0.7*T2<T1<0.9*T2 or 0.7<T1/T2<0.9 if you are sure T2 is not getting the value 0.
Re: How to call values from a table and then do the minerr() calculation?
Hi:
Now I understand T[2=T(subscript 2). I was using the same constraint. You also remind me the way to make constraint stronger by using 1000*(T[2-T[1)>0. Thanks!!
The concept of my work requires to lookup TTs induced "n" (take empirical values) from the same sheet (.xls file). The meaning of the theory to me is those equations (make_theory(TT), make_ntheta, make_Msum). Maybe this difference confused you. But current code is what we want for now.
While using LMA, I found that minerr() try to find proper TTs in sequence (means TT0 first, then TT1, TT2....), not in parallel. It is because sometimes calculated TT0=1.1TT1 (overshoot), even I setup TT0<0.9*TT1.
It usually happens at beginning TTs (TT0/TT1/TT2) but not TT2-TT25.
That means to me is that if changing TT0 is enough to satisfy a min ERR, other TTs won't be adjusted as I expect. Maybe this is the concept of LMA( I am not sure).
I will try the stronger constraint and see how it works.
I understand constraints are just for reference, not exact rule.
Maybe that's the reason calculated TT0=1.1TT1 (overshoot) when I setup TT0<0.9*TT1.
My curiosity is: if I setup TT0<0.9*TT1 and TT1=1, what could be the possible TT0?
I know "TT1<0.9*TT2 would mean that the ratio TT1/TT2 is in the range from -infinity to 0.9."
To my experence here, TT1/TT2 always try to shoot values close to 0.9.
If I know the possible range (maybe setup in MathCad like CTOL), it's easier to setup constraints.
Do you know in what situations people setup constraints when they use minerr()?
My goal is to use minerr() without setting up constraints. Since I am dealing with multiple TTs and approaching just one solution, maybe I cannot avoid it.
Re: How to call values from a table and then do the minerr() calculation?
Constraints would be necessary if there are multiple possible "solutions" and may help to find the one which fits "wishes" one may have.
Don't think that LMA would just try to change one parameter after the other but rather would work with the gradient vector (numeric derivatives) to do its job. You can think of a 25-dimensional "surface" in your case. For further details you may google for "Levenberg-Marquardt".
If you don't want to use additional constraints I guess you will have to settle for what minerr will give you.
BTW - what are the results with minimize()? Here CTOL would have more effect, I guess.
Re: How to call values from a table and then do the minerr() calculation?
While using LMA, I found that minerr() try to find proper TTs in sequence (means TT0 first, then TT1, TT2....), not in parallel.
No, it finds them in parallel.
I understand constraints are just for reference, not exact rule.
Maybe that's the reason calculated TT0=1.1TT1 (overshoot) when I setup TT0<0.9*TT1.
My curiosity is: if I setup TT0<0.9*TT1 and TT1=1, what could be the possible TT0?
I know "TT1<0.9*TT2 would mean that the ratio TT1/TT2 is in the range from -infinity to 0.9."
In minerr a constraint is a soft constraint, not a hard constraint. If TT1<0.9*TT2 means that the ratio TT1/TT2 is in the range from -infinity to 0.9, that's a hard constraint, because the ratio cannot exceed 0.9. If you want a hard constraint you must weight the constraint very heavily.
If I know the possible range (maybe setup in MathCad like CTOL), it's easier to setup constraints.
There is no way to know the exact range. The errors in the constraints are minimized along will the errors in the residuals. In essence, everything is a constraint; the residuals are constraints where certain differences should be equal to zero. So the possible magnitude of the error in a constraint depends on the possible magnitudes of the errors in all the other constraints, including the residuals. If you want a hard constraint, weight it heavily.
Re: How to call values from a table and then do the minerr() calculation?
Hi:
My expected solution should be a gradient.
I think minerr() with LMA is the best choose for now.
Look like minimize() doesn't have LMA option.
After using minimize(), with/without constriants cannot give a better solution.
Re: Error in PDEsolve function with system of PDE's
Don't know if the attached helps. It's an old file that I've modified to incorporate some of your data.
Alan
Re: Error in PDEsolve function with system of PDE's
Thank you so much Alan! Your sheet solved my problem!
Jaap