I am not a math expert nor a native English speaker, so maybe I am using wrong terminology... In this case, help me to improve my question :)
Part 1:
This is my set of equations, I have to calculate values $x_n$, $y_n$ and $z_n$. I know the values of $A, B, C$, Total and sums of parameters ($S_1$ = $x_1$ + $x_2$ + $x_3$, $S_2$ = $y_1$ + $y_2$ + $y_3$, $S_3$ = $z_1$ + $z_2$ + $z_3$). It is not necessary, that each equation gives us exactly the same result, but each equation should have its solution it's close to others as possible - in perfect case this would be $\text{Total}/3$.
$x_1A + y_1B + z_1C = \text{Total}/3$
$x_2A + y_2B + z_2C = \text{Total}/3$
$x_3A + y_3B + z_3C = \text{Total}/3$
I figured it out, this is a set of diophantine equations. I could solve this with a genetic algorithm:
- First randomly assign values $x_n$, $y_n$ and $z_n$ (just watch for the sum of parameters)
- Then mutate this numbers so, that the solution of each equation is as close to others as possible. By mutating I mean to increase one parameter while decreasing another and calculate fitness function.
Part 2:
I think the first solution should work (have to try it out though). But it was a simplification of my original problem, which is like this:
$i(x_1A + y_1B + z_1C) = \text{Total}/3$
$j (x_2A + y_2B + z_2C) = \text{Total}/3$
$k (x_3A + y_3B + z_3C) = \text{Total}/3$
Now the problem is, that I cannot just randomly increase/decrease parameters, because $i$, $j$ and $k$ could be different and hence the set of these equations could yield different solution as previous mutation. Also - $i$, $j$ and $k$ are not given, I have to calculate them by my self.
What is the best way to solve my two problems?
It looks like you have six equations, the three you list in the post and $x_1+x_2+x_3=y_1+y_2+y_3=z_1+z_2+z_3=S$, where $S$ is given to you. If we add the three equations in your post together we find $S(A+B+C)=Total$. As all the terms in this equation are givens, it had better be true. This will not apply to Part 2. So you have five equations in nine unknowns and it should not be hard to satisfy. If you just do a solution of linear equations you should find that there is a four parameter solution set and all the terms are rational multiples of each other. The only thing that can go wrong is for things to go negative.
For Part 2, it looks like $i, j, k$ are givens as well. You still have more unknowns than equations.
If I have misunderstood something, please help me out.