Skip to content Skip to sidebar Skip to footer

Problems With Scipy.optimize Using Matrix As Input, Bounds, Constraints

I have used Python to perform optimization in the past; however, I am now trying to use a matrix as the input for the objective function as well as set bounds on the individual ele

Solution 1:

Digging into the code a bit. minimize calls optimize._minimize._minimize_slsqp. One of the first things it does is:

x = asfarray(x0).flatten()

So you need to design your objFunc to work with the flattened version of w. It may be enough to reshape it at the start of that function.

I read the code from a IPython session, but you can also find it in your scipy directory:

/usr/local/lib/python3.5/dist-packages/scipy/optimize/_minimize.py

Post a Comment for "Problems With Scipy.optimize Using Matrix As Input, Bounds, Constraints"