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
We are now starting on some of the more advanced features and have been playing around with Maximize and Minimize. I found the minimise not to want to solve and playing around further I cam across the interesting conclusion that Mathcad cannot accommodate multiple accurences of maximize or minimize in the same document.
I duplicated this into a simple sheet duplicating the exact same command next to each other except that the answer is stored into different variables. When moving the one above the other they alternate in solving. This is rather irritating as our model needs to use the data generated to in one case maximize a value and in another case minimize another, but the second one simply does not want to solve.
Has anyone come across the same. Are we doing something wrong or is this a problem in Mathcad.
Please assist
BWB
The problem with CTOL and TOL
We must do CTOL and TOL := 10^-10 or work with m not cm - see please the attach
I do not see any difference changing the CTOl and TOL. Still doing the same. I on purpose deleted the units and only multiply that in in the last step. However, even if I remove them completely it still does the same.
Barend Botha wrote:
I do not see any difference changing the CTOl and TOL.
Prime - OK. An Error is only in 15 0010.
Make the Minimize solve block a function - see attached.
Alan
Making the minimize solve block a function now ignores the limitations given in the Given block, i.e. the limitation in this case is that the volume should be larger than 60 cub cm and both answers are smaller.
Actually the condition you have is that the volume should be greater than or equal to 60, and it comes out to be 60. I did however, leave out your condition that height must be twice the width (because you hadn't specified it correctly and I forgot to put it back after deleting your statement!). The attached puts this back in.
Alan
Allan
I am not sure if I am missing something, but as I see it the new volume calculated with the dimensions obtained is 0.o1 cm^3 and not 60 cm^3 and in the second case it is even much smaller. If it minimizes correctly surely using the solution of the previous minimimization should then get to the exact same answer. Please help.
Barend Botha wrote:
Allan
I am not sure if I am missing something, but as I see it the new volume calculated with the dimensions obtained is 0.o1 cm^3 and not 60 cm^3 and in the second case it is even much smaller. If it minimizes correctly surely using the solution of the previous minimimization should then get to the exact same answer. Please help.
Strange! here's a screen shot of what I get:
As you can see the volume is 60cm^3 and the repeat calcs are the same as the original.
Are you using my worksheet or have you modified your own. If the latter, please upload it so I can investigate.
Alan
Allan
Screen shot from opening your file on my machine.
This is really strange and concerning.
Thanks
Barend
My default units are SI if that maybe makes a difference.
Barend Botha wrote:
My default units are SI
So are mine! That means that volumes will be displayed in m^3 by default, but if you click the little black square that appears when you click on m^3 you can simply type in cm^3 and Mathcad will display in those units.
Alan
Correct, but they are stored in m^3. Just thought there might be a conversion error if you were working in English units. I started ignoring the units when it did not want to solve.
Barend
Barend Botha wrote:
Correct, but they are stored in m^3. Just thought there might be a conversion error if you were working in English units. I started ignoring the units when it did not want to solve.
Barend
If you are going to ignore units then you need to remove them entirely (your original file had a mix with some items with units and others not!) and make sure your calculations are consistent. In general you can enter values in whatever units you like (as long as you specify them at the time you enter the values) and Mathcad will convert to standard SI in which to do all its calculations and default display of results. You can then modify the display to whatever system of units you like (as long as Mathcad knows about them!).
Alan
Alan
I thought the file I uploaded had the units all removed except at the end I multiplied cm in after minimizing. I am attaching a newer version which I have not modified except for calculating the volume and area for the L2, W2 and H2 values as well.
However, no difference in result anyway.
Alan
I rewrote your function option into my original and itworks nicely. I then changed the limitation again and that also works given that you rewrite the function (I am assuming so that it can pick up the limitation). I am attaching the file.
Thanks very much for all your trouble. I will be able to manipulate it from here.
The fact that I got completely different answers when opening your worksheet is, however, a concern. How do I prevent this from happening when sharing workbooks with other people. We are trying to get the company to convert to Mathcad and those resisting would love to see this happening, even more so if I cannot explain it.
Barend
Barend Botha wrote:
Alan
I rewrote your function option into my original and itworks nicely. I then changed the limitation again and that also works given that you rewrite the function (I am assuming so that it can pick up the limitation). I am attaching the file.
Rewriting the function is unnecessary. You can simply add the limiting volume as an input variable. The only oddity in doing this with Minimize is that you have to add it as an input variable to the function being minimised, even though it's not used in that function! See attached.
Barend Botha wrote:
The fact that I got completely different answers when opening your worksheet is, however, a concern. How do I prevent this from happening when sharing workbooks with other people. We are trying to get the company to convert to Mathcad and those resisting would love to see this happening, even more so if I cannot explain it.
I've no idea why this problem occurs I'm afraid; it's not one that I've come across before.
Alan
Thanks
Barend
and that also works given that you rewrite the function (I am assuming so that it can pick up the limitation).
You may consider adding the volume as a parameter to your function dimensions. (see attached sheet)
The fact that I got completely different answers when opening your worksheet is, however, a concern. How do I prevent this from happening when sharing workbooks with other people.
I also get wrong results with Alans sheet. This is, as I had already written in a previous post, because Alan used units consequently and as you need an accuracy in cm and not the base unit m you need to lower the system variable CTOL (either via the menu options or directly in the sheet) to something like 10^-10. Nevertheless it was surprising to me that the miminize solve block is that sensitive to CTOL. The solve block will not find a solution if CTOL is set too low. You can see this in the attached sheet - it fails for values of CTOL lower than the 10^-3 if the function is with units m or without units - surprising again.
I, too, get something odd with my last file that doesn't have units as I change CTOL. However, if I include units everything seems to work ok! See below and attached!
Alan
Hmm, not sure whats the matter here. I am using the current Mathcad 15 M030 and using the sheet you just posted I get the following (the second call yielding L2. etc should not be necessary):
As options like unit system used, value of CTOL, compatibilty options, etc all are worksheet options the only thing I can think is that you are using a differnt version of Mathcad. On the other hand if I read correctly a previous post from Valery looking at his screenshot he got the same wrong results with MC15 M010.
Alan, which version of Mathcad are you using and have you ever tampered with the files associated with the unit systems?
On the same sheet, if I put my CTOL and TOL to 10^-5 or smaller it cannot find a solution. I therefore have to go with 10^-3 to get the solution, which is then right (same L and L2 values), but completely different from yours. If I take 10^-4 the values are no longer the same (4.9 vs 4.93) but at 10^-5 there is no solution.
I used the last worksheet Alan sent here http://communities.ptc.com/message/236148#236148 and simply added CTOL:=10^-whatever before the first "Given".
And you don't get solutions with 10^-6 and solutions different from mine with CTOL=10^-3 ?? Using the very same sheet unchanged? Incredible! Which version and mainanance release are you using?
Alan/Val
Thanks, solving on my machine gives the right answers and no differance between answers. However, taking the 2c version you sent earlier and going with 10^-10 as suggested it does also give me the right answer. This is kind of weird and it would be good to be able to defend it. The question remains that the person using your spreadsheet might not have CTOL and TOL set to that level and will still get an answer, but a completely wrong answer. This creates a huge risk which those that want to resist the move to Mathcad will gladly exploit. Would be great if we could find a solution.
This is kind of weird and it would be good to be able to defend it.
I guess the lesson we can draw from this thread is to avoid using units in that kind of solve block (not sure if only minimize and maximize are affected). I tried to create a more simple example - finding max/min of a sine - but even the use of ms and mV worked as expected. Not sure whats so special with your sheet, but the effect of Alan, you and me getting three different results from the same sheet is spooky! It really looks like a bug but its hard to trace it down giving so different results for different people, so its probably not a candidate for a call to PTC support.
The question remains that the person using your spreadsheet might not have CTOL and TOL set to that level and will still get an answer, but a completely wrong answer.
That should not be a problem as the settings of TOL and CTOL are worksheet options. So they travel with the worksheet and are not bound to the installation. The same goes for the unit system used. But to be reassured and on the safe side you can put CTOL:=... at the top of your sheet. That way its also easier to change that value compared to the method via menu.
Thanks. I must say, getting different answers is extremely spooky.
I am not sure about the problem you are experiencing. I guess the problem you posted in your sheet is not the problem you actually want to solve. In your post you wrote that you want first to maximize one problem and use the results as guess values to minimize a second problem. In your sheet you are simply trying to do the same minimization twice which doesn't make much sense as does the condition >=60 instead of =60 as it must be clear the volume in the problem you posted has to be exactly 60 cm^3 (if a solution would be found for a greater volume you could cut the height and get a better solution).
Basically your sheet has the structure
Given
... constraint(s)
Sol:=Minimize(....)=
Sol:=Minimize(....)=
You have to think of "Given" and "Minimize" as opening and closing parenthesis.
So the second time Minimize is used standalone without a solve block (no associated Given). It will use no constraints and the current values of l.min etc. as guesses (which are the initial 1's in your sheet!). This standalone Minimize fails with an improper error message (variable not found) because we would get a minimum (w/o constraints) for variables being minus infinity.
If you move the second Minimize above the first it gets associated with the given and the other will be the one which is standalone.
So in case your original problem requires two different optimizations with different constraints, the solution is to use a solve block for the second optimizatioin, too. Keep in mind that constrains only are considered if the are stated IN the solve block (between Given and Maximize, minimize, Find, or ,,,,).
If the problem you posted really is the one you want to solve, see the attached file. There is no need for a second minimize.
If you chose the more elegant way and add units to your variables from the beginning as Alan had doen, you will have to change CTOL to a much smaller value than the default 10^-3 as Valery suggested because Mathcad will use its tolerances on the values in base units (meter in your case).