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, made from equations that I pass as delegates:
delegate 1) x4 + f(x4,x2,x3) -2 = 0
delegate 2) g(x1,x2) - 0.5 = 0
delegate 3) h(x1,x2) + x1*x3 - 5 = 0
delegate 4) x3*x4 - 2 = 0
Here, f g and h are some functions that return a float. The way the solver works is try different combinations of an input vector [a, b, c, d] corresponding to the union of all unknowns provided by the delegates, following some algorithm until all roots are found by iteration.
My problem is that each delegate of the above system is provided by a different class. This is actually a problem because the delegate number 1, which is a function defined in a different class elsewhere, needs to now that its parameters x2,x3,x4 correspond to the values b,c,d from the input vector... but it doesn't know that unless there exists some kind of mapping defined somewhere(?).
It would seem that there is a dependency between the solver and the delegates 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