paveltrutman / polyopt Goto Github PK
View Code? Open in Web Editor NEWPolynomial optimization problem solver. Uses relaxation to convert the problem into Semidefinite programming. Can be also used just as Semidefinite programming solver.
Polynomial optimization problem solver. Uses relaxation to convert the problem into Semidefinite programming. Can be also used just as Semidefinite programming solver.
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:
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?
Hi,
All over your code, you cite 'Nesterov', with pages numbers. Could you provide the full reference to this book ? I have troubles matching the pages numbers, since there might have been a re-edition, so if you provide the full reference you used it would be great ๐
Nice code btw.
Hi, I've successfully installed the package polyopt according to the instruction on your webpage. But when I enter Python and import polyopt, I got the following error message:
import polyopt
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\tong.chen\polyopt\polyopt_init_.py", line 3, in
from .SDPSolver import SDPSolver
File "C:\Users\tong.chen\polyopt\polyopt\SDPSolver.py", line 6, in
import gnuplot as gp
File "C:\Users\tong.chen\AppData\Local\Continuum\anaconda3\lib\site-packages\gnuplot_init_.py", line 164, in
from gnuplot.gp import GnuplotOpts, GnuplotProcess, test_persist
File "C:\Users\tong.chen\AppData\Local\Continuum\anaconda3\lib\site-packages\gnuplot\gp.py", line 31, in
from gnuplot.gp_win32 import GnuplotOpts, GnuplotProcess, test_persist
File "C:\Users\tong.chen\AppData\Local\Continuum\anaconda3\lib\site-packages\gnuplot\gp_win32.py", line 12, in
import Errors
ModuleNotFoundError: No module named 'Errors'
Could someone help me fix this issue please?
Thanks in advance!
Hi,
I do want to solve the SDP problem from example (4.1) in this paper. This problem seem quite easy to solve, but i do not manage to make it work using polyopt.
Could you explain to me how i should translate it's expression to the polyopt SDPsolver ? It keep running until values goes +/- np.inf and LocalNormA returns an error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.