This might sound like a maths questions but it is really more of a programming design question.
Imagine I have already implemented in C# a multidimensional root solver to find the unknowns of the following system:
1) x4 + f(x4,x2,x3) -2 = 0
2) g(x1,x2) - 0.5 = 0
3) h(x1,x2) + x1*x3 - 5 = 0
4) x3*x4 - 2 = 0
Here, f g and h and functions that return a float. The way the solver works is try different combinations of [x1,x2,x3,x4] in a particular way until it finds all roots.
My problem is that each function of the above system is provided by a different class. This is actually a problem because the class providing 1) is unaware that the unknown x1 exists, but it needs to know from which positions to get x2,x3 and x4 from the input argument vector, to then check whether a root has been found.
It would seem that there is a dependency between the solver and the functions provided by each class. Is there a way that I can design my system so that each function knows where to get the corresponding x values from, so that the solver can do its work? I have been thinking of implementing hash-tables and create identifiers for each parameter but it all seems quite naff to me.
In practice, I will be working with a system with over 1000 equations and 1000 unknowns with the problems above described.
Is there a data structure or pattern that can help me here?
Aucun commentaire:
Enregistrer un commentaire