Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi, I am quite new to mathcad and need help with the following problem:
a*u+b*v-c*w+d*uv = y
a=1.4
b=0.3
c=0.5
d=0.2
u, v, w are variables that fulfill some constraints:
0.2<u<0.8
0.1<v<0.5
0<w<0.7
and
u+v+w=1
and
u, v, w can only have values like u = 0.2, 0.3, 0.4, ... but not 0.25 or 0.21. (I am sure there is a mathematical term for numbers as such, sorry)
Now, I want mathcad to give me all possible solutions (all different compositions of u, v, w) that fulfill y > 2.
Thanks for any help.
Max
Solved! Go to Solution.
Here you are, but with more variables and maybe a wider range a brute force approach can be a problem - at least with respect to calculation time.
As you didn't specify the datastructure of your results I chose a nested vector. Each vector element is a 1x3 matrix consisting of the three values for u, v and w.
BTW, the testproblem you had set up has no solution as you can see here:
d*uv should be d*u*v ???
yes, not a differentiation
ehh, deduction
Max Muehle wrote:
ehh, deduction
derivative, derivation
(Differential, Ableitung)
Do you have three different values for v as you wrote (0.1<v<0.5) are do you mean 0.1<=v<=0.5 ?
🙂 derivative, ok.
no, not three different values, but five:
v= 0.1, 0.2, 0.3, 0.4, 0.5
u has six values:
u= 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8
and w has seven values.
so, yes:
0.1<=v<=0.5
but with the constraint that it can only be a full decimal
So you should have written <= instead of <.
What version of Mathcad are you using. What have you tried so far?
I don't think that Mathcad's built-in solver facilities would help. The numeric solvers will give you the first solution thea will find and stop and symbolic evaluation will probably ignore or choke at constraints like "trunc(10*u)=10*u" to ensure that the tenfold of your variables is an integer.
So all I could think of at the moment is writing a small program in Mathcad (or any other programming language) to try all possibilities. This brute force attack should not be to bad here as you only have 280 combinations to try.
I am using mathcad 15 and so far I've been watching a whole lot of youtube-videos about solve-blocks that don't help.
The equation and the constraints are only placeholders - the real equation actually has 10-15 variables. And I wouldn't know where to start with writing a program to run through the combinations.
Thank you for your time,
Max
Here you are, but with more variables and maybe a wider range a brute force approach can be a problem - at least with respect to calculation time.
As you didn't specify the datastructure of your results I chose a nested vector. Each vector element is a 1x3 matrix consisting of the three values for u, v and w.
BTW, the testproblem you had set up has no solution as you can see here:
Thank you very much.
I will try to adapt your solution to my equation tonight.
Max
Max Muehle wrote:
Thank you very much.
I will try to adapt your solution to my equation tonight.
Max
Good luck!
As you have a more complex problem it may help to reduce calculation time if you replace the if loops with while-loops or use break inside the if. For instance in the example above my program will try w=0.1 to 0.7 even when u+v equals already 1. So if u+v+w>1 the w-loop can be breaked immedeatly.
Implementing that kind of shortcuts make the program much mor cluttered (and failure prone) but may reduce calc time heavily.
Even with the simple example we get a speed improvement of 10-20% by just inserting two simple break commands. Depending on the real problem and the constraints there there might be much more potential for improvements.