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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Passing variables to a solver dynamically

ptc-4356237
1-Visitor

Passing variables to a solver dynamically

Dear PTC Community,

I'm writing a MATHCAD solver block for a system that consists of 29 variables and 11 equations. The objective is to write a solver that can handle any combination of 11 unknowns from the set of 29 total variables. It is straightforward to write the solver if it is known in advance which variables are unknown. For that case, one simply assigns values to all 29 variables in the "guess" section, enters the 11 equations into the "constraints" section, and enters a single find function in the "solver" section that is passed the 11 variables whose values are to be found, something like "MyVector := find(var1,var2,...,var10,var11)".

What is more difficult is to make the solver dynamic so that any combination of 11 unknowns is solved for. As far as I know, you can't pass a vector as an argument to find, so I can't write "find(unknownVector)", because find wants to see variables or functions. Any ideas?

Regards,

James

6 REPLIES 6
wayne
12-Amethyst
(To:ptc-4356237)

Possibly:

Write the solve block as a function, like g(x,y,z):=Minimize(f,x,y,z)

Then write a program to accept input matrix, and assign to the appropriate variables and guess values in the program and then call the function.

But you have to discern which variables you are using, possibly by including all 29 and assigning NaN for the ones you are not using, or use a second matrix whose elements assign a number (0-29) corresponding to each element of the input matrix so the appropriate variable assignments can be made in the program.

Do the equations depend on which variables you select, and are they linear?

Something like the above, or way off?

Wayne, this looks like a promising approach. Allow me to tinker with it a bit and let you know if it works.

Wayne Reid wrote:

Possibly:

Write the solve block as a function, like g(x,y,z):=Minimize(f,x,y,z)

Vote please - http://communities.ptc.com/polls/1131

Hello!

Please attach your Mathcad worksheet.

Vladimir,

The worksheet is attached.

Regards,

James

James Maddox wrote:

Dear PTC Community,

I'm writing a MATHCAD solver block for a system that consists of 29 variables and 11 equations.

Regards,

James

May be this (3 variables and 3 equations) help you:

http://twt.mpei.ac.ru/ochkov/Mathcad_14/Chapter3rus/3-43-u-bot-2.PNG

Announcements

Top Tags