'How to Solve System of Equations When Some Variables Are Already Chosen?

I'm using scipy.optimize to minimize a cost function.

Python passes M variables into the cost function, and N other variables are calculated based on those. Now, I have a system of M+N simultaneous equations which must be satisfied for a solution to be valid.

I imagine doing something like this:

def cost(someTuple):
    # This function calculates the cost
    return k1 * someTuple[0] + k2 * someTuple[1] + ... kN * someTuple[N-1]

def cost_wrapper(x):
    # ************ The following line is what I don't know how to do *************
    big_tuple = solveSystemOfEquations(x, f(x))
    return cost(big_tuple)

if __name__=="__main__":
    from scipy.optimize import minimize
    minimize(cost_wrapper, *otherParams)

What is important about solveSystemOfEquations() is that it returns more variables than are given to it. If the variables given to it are far removed from any possible solution, solveSystemOfEquations() has to return a large number with a gradient that will lead the optimizer towards a meaningful solution.

Let's also assume that the system is approximately solvable. Note that boundedness of MMSE error of a solution cannot be guaranteed.

Is there any algorithm which allows you to choose some (not all) variables, and solve for the others? Or is that not a thing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source