Basically my problem is this:

where all the a's, b's, and c's are known constant coefficients, the k's are known constants, and the p's are variables.

I'm also given the equation

Where the d's are known constant coefficients, and total is an unknown constant.

My objective is to use either a "for" or "while" loop to find the values of

that produce the highest value for "total"

my initial thoughts were to create a coefficient matrix and a variable matrix multiplied together to get the resultant matrix, then simply divide the resultant matrix by the coefficient matrix to get the values for the variable matrix.

Obviously, this didn't work. So I come to you MathHelpForum.

I'm not looking for a final solution (thus the entirely symbolic problem presented). Simply direction on how to proceed. Whether it be a tip on the proper loop structure to use, or how to set up the matrices properly