You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all, thanks for this package, it is really what I was looking for!
I'm trying to use it to optimize a simple 1d polynomial, with no constraints, but I'm getting this error:
Traceback (most recent call last):
File "/home/student/repos/polyopt/demoPOPSolver.py", line 27, in <module>
POP = polyopt.POPSolver(f, g, d)
File "/home/student/repos/polyopt/polyopt/POPSolver.py", line 37, in __init__
if max(gDegsHalf) > d:
ValueError: max() arg is an empty sequence
I guess the solver is not done for the unconstrained case. I was able to get around this by adding a dummy constraint (x+100>=0). Here is the code I'm running now:
f = {(0,): 5, (1,): -2, (2,): 1}
g = [{(0,): 1e2, (1,): 1,}] # constraint function x + 1e2 >=0
d = 2
POP = polyopt.POPSolver(f, g, d)
y0 = POP.getFeasiblePoint([array([[1]]), array([[2]]), array([[-1]]), array([[-2]])])
POP.setPrintOutput(False)
x = POP.solve(y0)
However, I still get an error:
x = POP.solve(y0) #solve the problem
File "/home/student/repos/polyopt/polyopt/POPSolver.py", line 80, in solve
y = self.SDP.solve(startPoint, self.SDP.dampedNewton)
File "/home/student/repos/polyopt/polyopt/SDPSolver.py", line 188, in solve
x0 = method(start)
File "/home/student/repos/polyopt/polyopt/SDPSolver.py", line 314, in dampedNewton
FdLN = Utils.LocalNormA(Fd, Fdd)
File "/home/student/repos/polyopt/polyopt/utils.py", line 29, in LocalNormA
return sqrt(dot((solve(hessian, u)).T, u))[0,0]
File "<__array_function__ internals>", line 6, in solve
File "/home/student/.local/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 399, in solve
r = gufunc(a, b, signature=signature, extobj=extobj)
File "/home/student/.local/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 97, in _raise_linalgerror_singular
raise LinAlgError("Singular matrix")
numpy.linalg.LinAlgError: Singular matrix
This time I'm not sure what the problem is. Any suggestion?
Moreover, would it be simple to modify the code to handle unconstrained minimization?
The text was updated successfully, but these errors were encountered:
Some additional info. I've tried reducing the degree of the relaxation d to 1, but nothing changed.
If I enable the output of the solver I get a lot of stuff printed, which ends with this:
k = 1035
y = [[4.27207552e+080]
[4.51955469e+161]]
EIG[0] = [1.00000000e+000 4.51955469e+161]
EIG[1] = [4.27207552e+80]
k = 1036
y = [[4.68619274e+080]
[5.70445470e+161]]
EIG[0] = [1.0000000e+000 5.7044547e+161]
EIG[1] = [4.68619274e+80]
k = 1037
y = [[5.60596174e+080]
[8.12844091e+161]]
Problem solved. Reviewing the theory I've seen that the feasible set needs to be bounded, so I added the constraint 1e4 - x^2>=0 to my problem and now the solver gives me a solution. However, very often it's not a good solution. For instance, for a polynomial with these coefficients:
a [ 0.81115 -0.45637 -0.3268 0.52828 0.24135]
I get the following solution:
Global minimum f(x)=[42.68568] at x=[21921.42697]
While using BFGS and another scipy solver to optimize the same polynomial I get
Scalar-opt minimum f(x)=0.01851134671778265 at x=[-1.86858]
BFGS minimum f(x)=0.564046131707772 at x=[0.62908]
I've tried playing with the degree of the relaxation, trying 1, 2, and 3, but I always get this kind of problems. Any suggestion?
Hi,
first of all, thanks for this package, it is really what I was looking for!
I'm trying to use it to optimize a simple 1d polynomial, with no constraints, but I'm getting this error:
I guess the solver is not done for the unconstrained case. I was able to get around this by adding a dummy constraint (x+100>=0). Here is the code I'm running now:
However, I still get an error:
This time I'm not sure what the problem is. Any suggestion?
Moreover, would it be simple to modify the code to handle unconstrained minimization?
The text was updated successfully, but these errors were encountered: