Code Monkey home page Code Monkey logo

ncvx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ncvx's Issues

Can't install SCSPROX

pip install scsprox doesn't work

I tried to install from source( https://github.com/bettbra/scsprox ) and it doesn't work too, I get the following error:

python setup.py install
running install
running bdist_egg
running egg_info
writing scsprox.egg-info/PKG-INFO
writing dependency_links to scsprox.egg-info/dependency_links.txt
writing requirements to scsprox.egg-info/requires.txt
writing top-level names to scsprox.egg-info/top_level.txt
reading manifest file 'scsprox.egg-info/SOURCES.txt'
writing manifest file 'scsprox.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/scsprox.py -> build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/examples.py -> build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/verify.py -> build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/prox_obj.py -> build/bdist.linux-x86_64/egg/scsprox
creating build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_top_level.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_location.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_prox_obj.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_memory.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_prox_info.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_sol_extract.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/init.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/test/test_settings.py -> build/bdist.linux-x86_64/egg/scsprox/test
copying build/lib/scsprox/scs_mapping.py -> build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/init.py -> build/bdist.linux-x86_64/egg/scsprox
copying build/lib/scsprox/timer.py -> build/bdist.linux-x86_64/egg/scsprox
byte-compiling build/bdist.linux-x86_64/egg/scsprox/scsprox.py to scsprox.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/examples.py to examples.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/verify.py to verify.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/prox_obj.py to prox_obj.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_top_level.py to test_top_level.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_location.py to test_location.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_prox_obj.py to test_prox_obj.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_memory.py to test_memory.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_prox_info.py to test_prox_info.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_sol_extract.py to test_sol_extract.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/init.py to init.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/test/test_settings.py to test_settings.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/scs_mapping.py to scs_mapping.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/init.py to init.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scsprox/timer.py to timer.cpython-37.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scsprox.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating 'dist/scsprox-0.2.0-py3.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing scsprox-0.2.0-py3.7.egg
removing '/usr/local/lib/python3.7/site-packages/scsprox-0.2.0-py3.7.egg' (and everything under it)
creating /usr/local/lib/python3.7/site-packages/scsprox-0.2.0-py3.7.egg
Extracting scsprox-0.2.0-py3.7.egg to /usr/local/lib/python3.7/site-packages
scsprox 0.2.0 is already the active version in easy-install.pth

Installed /usr/local/lib/python3.7/site-packages/scsprox-0.2.0-py3.7.egg
Processing dependencies for scsprox==0.2.0
Searching for cyscs
Reading https://pypi.org/simple/cyscs/
Downloading https://files.pythonhosted.org/packages/58/46/01b1bdd38d94f418c85914c2d373c38b143f4271ad91c923256a2c336224/cyscs-0.1.tar.gz#sha256=a0aec7da3f8afaf92665b202fcd52ce7fb43ecf9e55b3fbe87f8ff5c002fa581
Best match: cyscs 0.1
Processing cyscs-0.1.tar.gz
Writing /tmp/easy_install-dbpyas6b/cyscs-0.1/setup.cfg
Running cyscs-0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dbpyas6b/cyscs-0.1/egg-dist-tmp-f5r8rwzm
Trying 'lapack_opt'
/usr/local/lib/python3.7/site-packages/numpy/distutils/system_info.py:1989: UserWarning:
Optimized (vendor) Blas libraries are not found.
Falls back to netlib Blas library which has worse performance.
A better performance should be easily gained by switching
Blas library.
if self._calc_info(blas):
the resulting info is: {'libraries': ['lapack', 'lapack', 'blas', 'blas'], 'library_dirs': ['/usr/lib/x86_64-linux-gnu'], 'language': 'c', 'define_macros': [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None), ('LAPACK_LIB_FOUND', None)], 'include_dirs': ['/usr/local/include', '/usr/include']}
error: Setup script exited with error: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYTHON -DDLONG -DCTRLC=1 -DCOPYAMATRIX -DNO_ATLAS_INFO=1 -DHAVE_CBLAS -DLAPACK_LIB_FOUND -Ic/scs/ -Ic/scs/include -Ic/scs/linsys -I/usr/local/include -I/usr/include -I/usr/local/lib/python3.7/site-packages/numpy/core/include -Ic/scs/linsys/direct/ -Ic/scs/linsys/direct/external/ -I/usr/local/include/python3.7m -c cyscs/_direct.c -o build/temp.linux-x86_64-3.7/cyscs/_direct.o -O3" failed with exit status 1

examples/tsp.py - "IndexError: index 0 is out of bounds for axis 0 with size 0"

Hey Steven,

This library looks great. I'm excited to try out some of the examples. I noticed that running examples/tsp.py returns an error:

DN0a22a81f:examples mike$ python tsp.py
lower bound = -inf
Traceback (most recent call last):
  File "tsp.py", line 71, in <module>
    max_iter=50)
  File "/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cvxpy-0.4.9-py2.7.egg/cvxpy/problems/problem.py", line 207, in solve
    return func(self, *args, **kwargs)
  File "/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/ncvx-0.1.4-py2.7.egg/ncvx/admm_problem.py", line 270, in admm
    prox_polished, polish_depth, lower_bound, alpha, args, kwargs) for idx, rho_val in enumerate(rho)])
  File "/Applications/Canopy.app/appdata/canopy-1.7.4.3348.macosx-x86_64/Canopy.app/Contents/lib/python2.7/multiprocessing/pool.py", line 251, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/Applications/Canopy.app/appdata/canopy-1.7.4.3348.macosx-x86_64/Canopy.app/Contents/lib/python2.7/multiprocessing/pool.py", line 567, in get
    raise self._value
IndexError: index 0 is out of bounds for axis 0 with size 0

Note that I was able to successfully run examples/circle_packing.py.

an unexpected keyword argument 'sign'

Hello! Thank you for distributing this code.
I was trying to run the examples. However, it gives me the error message "an unexpected keyword argument 'sign'".
I'm using cvxpy==1.0.31 and ncvx==0.1.9.
Is there anything else I'm missing here?
One problem is I have to use python2.7 given that the system I'm using is not up-to-date and I'm not authorized to update it.
Thanks!

expose "BaseCost" for extension

I have a suggestion. In costs.py file, only 'HcostModel' and 'TcostModel' are exposed. Would it be better to expose 'BaseCost' for extension as well?

'Relax' method not found for Integer problem

x = Integer(int(len(df)), M=m)    
objective = sum_squares(x.T*df['calories'].values-cal_req)
prob = Problem(Minimize(objective),constraints)
prob.solve(method="relax")

Error message:
----> 1 res, totals= solve_int_bounded_relax(sample_df,cal,ub_lb_reqs_df, 5, mac_cols, nut_cols )

in solve_int_bounded_relax(df, cal_req, bounded_reqs_df, m, mac_cols, nut_cols)
14 objective = cvx.sum_squares(x.T*df['calories'].values-cal_req)
15 prob = cvx.Problem(cvx.Minimize(objective),constraints)
---> 16 prob.solve(method="relax")
17
18 df['total']= np.asarray(x.value).reshape(-1)

C:\Anaconda3\lib\site-packages\cvxpy\problems\problem.py in solve(self, *args, **kwargs)
204 func_name = kwargs.pop("method", None)
205 if func_name is not None:
--> 206 func = Problem.REGISTERED_SOLVE_METHODS[func_name]
207 return func(self, *args, **kwargs)
208 else:

KeyError: 'relax'

pip version doesn't import

/Users/davej/anaconda2/anaconda/lib/python2.7/site-packages/ncvx/init.py in ()
29 from .rank import Rank
30 from .sphere import Sphere
---> 31 from .soc_boundary import SOCBound
32 from .tour import Tour

ImportError: No module named soc_boundary

I can install and import from github version. Might want to update pip.

question about how nonconvex variables are handled

Hi,

Before I start using this package, I'd like to know if it is possible for me to apply the solver on a non-convex trajectory planning problem where the non-convex set comes from the collision avoidance constraints (or costs) between any 2 agents?
I am trying to find the fastest solver that I can use to solve trajectory planning problems in a receding horizon fashion, but using general-purpose nonlinear solvers such as IPOPT is way too slow when the number of agents is merely 2 or 3, which becomes intractable beyond 3 agents (each agent is modelled as a point mass..) . So any help is greatly appreciated!

error encountered while installing ncvx

Hi,

I have successfully installed scsprox, but when I tried installing ncvx using pip, the following occured:

(ICON_lab) randychen233@Randy-Desktop:~/projects/ICON_lab/ncvx$ pip install ncvx
Collecting ncvx
  Using cached ncvx-0.2.0.tar.gz (12 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in ncvx setup command: use_2to3 is invalid.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I also tried installing from source, but another error occurred:

(ICON_lab) randychen233@Randy-Desktop:~/projects/ICON_lab/ncvx$ python setup.py install
error in ncvx setup command: use_2to3 is invalid.

None of the examples in ncvx/examples that use NC-ADMM run properly

For a personal research project I am trying to reproduce the numerical experiments that use NC-ADMM in the paper:

"A General System for Heuristic Solution of Convex Problems over Nonconvex Sets by S. Diamond, R. Takapoui, and S. Boyd"

and compare the performance with nonconvex Douglas-Rachford splitting.

But none of the examples in ncvx/examples that use NC-ADMM run properly. I followed the instructions exactly as told in Readme, but each of the NC-ADMM examples throws errors. I have Python 2.7, latest Anaconda, CVXPY and NCVX. Any help will be appreciated.

examples/max_coverage.py - "TypeError: 'Prox' object is not callable"

Hey Steven,

Running examples/max_coverage.py also returns an error for me:

DN0a22a81f:examples mike$ python max_coverage.py
Traceback (most recent call last):
  File "max_coverage.py", line 24, in <module>
    prob.solve(method="NC-ADMM", parallel=False, verbose=True, polish_depth=0, restarts=1)
  File "/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/cvxpy-0.4.9-py2.7.egg/cvxpy/problems/problem.py", line 207, in solve
    return func(self, *args, **kwargs)
  File "/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/ncvx-0.1.4-py2.7.egg/ncvx/admm_problem.py", line 279, in admm
    prox_polished, polish_depth, lower_bound, alpha, args, kwargs) for idx, rho_val in enumerate(rho)])
  File "/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/ncvx-0.1.4-py2.7.egg/ncvx/admm_problem.py", line 90, in admm_inner_iter
    x1 = prox(x0, rho_val)
TypeError: 'Prox' object is not callable

Am I on the wrong version of something? As far as I'm aware, I have the latest version of cvxpy and the latest version of ncvx. Note that I was able to successfully run examples/circle_packing.py.

show_progress not defined in admm_problem

When running
python examples/job_selection.py

Traceback (most recent call last):
File "job_selection.py", line 34, in
val, resid = prob.solve(method="relax-round-polish", polish_depth=5)
File "/Users/davej/anaconda2/anaconda/lib/python2.7/site-packages/cvxpy/problems/problem.py", line 171, in solve
return func(self, _args, *_kwargs)
File "/Users/davej/anaconda2/anaconda/lib/python2.7/site-packages/ncvx-0.1.3-py2.7.egg/ncvx/admm_problem.py", line 306, in relax_round_polish
0, polish_depth, show_progress)
NameError: global name 'show_progress' is not defined

When to use strncpy or memmove?

11

You should never use strncpy (unless you are dealing with that rare specific situation it was introduced for). The function is not intended to be used with zero-terminated C-strings. The name given to that function is just a historical blunder, and happens to be the main source of the confusion for the people who attempt to use it. strncpy is a function introduced to support so-called "fixed width" strings, not zero-terminated strings. Using strncpy with zero-terminated strings is bad programming practice, even though you can whip it into some resemblance of "working" for that purpose.

A function for limited length "safe" string copying does not exist in C library, however some implementations provide it under the name strlcpy, which already became a de-facto standard name for this function. If your implementation does not provide strlcpy, implement it yourself.

Also, it is true that in many cases you can replace str... function with mem... functions, i.e. when you know the exact number of characters to copy.

ncvx/examples/circle_packing.py - "TypeError: ABCMeta object argument after * must be an iterable, not numpy.int64"

I am trying to run the circle_packing.py example (located in ncvx/examples/). My python is 2.7, cvxpy is 1.0.8 and I believe all other packages are up to date. To make the code compatible with cvxpy 1.0.8, I have changed:
objective = cp.Minimize(cp.max_elemwise( *(x_vals + y_vals) ) + 0.5)
to
objective = cp.Minimize(cp.maximum( *(x_vals + y_vals) ) + 0.5)

However, while running the circle_packing.py I am getting the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-9-2615d25cb940> in <module>()
      3     for j in range(i+1,N):
      4         t = cp.Variable()
----> 5         diff_vars.append(ncvx.Annulus(2, 0.5 * (r[i]+r[j]), N))
      6         constraints += [
      7             cp.vstack(x_vals[i] - x_vals[j],

/home/shuvomoy/anaconda2/lib/python2.7/site-packages/ncvx/annulus.pyc in __init__(self, rows, r, R, *args, **kwargs)
     28         self.R = R
     29         assert 0 < r <= R
---> 30         super(Annulus, self).__init__(rows, 1, *args, **kwargs)
     31 
     32     def _project(self, matrix):

/home/shuvomoy/anaconda2/lib/python2.7/site-packages/ncvx/noncvx_variable.pyc in __init__(self, *args, **kwargs)
     28         super(NonCvxVariable, self).__init__(*args, **kwargs)
     29         self.noncvx = True
---> 30         self.z = cvxpy.Parameter(*self.size)
     31         self.u = cvxpy.Parameter(*self.size)
     32         self.u.value = np.zeros(self.size)

TypeError: ABCMeta object argument after * must be an iterable, not numpy.int64

Any help in fixing the issue will be much appreciated.

Not accounting for 'z' cones in NC-ADMM yields ValueError: The cones must match the number of rows of A

Hello,

So I have been trying to implement tsp.py with NC-ADMM method. However I kept getting the error "ValueError: The cones must match the number of rows of A". I investigated further and printed the cone dictionary that is being passed through cyscs.Workspace() and got this for n = 60 (TSP number of cities parameter):

cone {'l': 10800, 'q': [3602], 'ep': 0, 's': [], 'p': [], 'z': 60}

Initially I thought this can be corrected by making edits to "cyscs/_utils.py" by:

  1. Including an extra if condition in cone_len(cone) function to find a 'z' key in the cone dictionary and update the cone count with the value of cone['z'] (i.e. include an additional condition: if 'z' in cone: total += cone['z'])
  2. by incorporating 'z' key in the format_and_copy_cone(cone) function's first for loop. (i.e. change for key in 'f', 'l', 'ep', 'ed': to for key in 'f', 'l', 'ep', 'ed', 'z':)

However, this did not make the cut. That is when I noticed the problem is deeper than that. In "scsprox/scs_mapping.py" we define the following:
@property def cone_dims_for_scs(self): return dims_to_solver_dict(self._data['dims'])
and that is where the problem seems to lie. Because, the self._data['dims'] returns (zero: 60, nonneg: 10800, exp: 0, soc: [3602], psd: [], p3d: []) where I assume p3d corresponds to 'z' (Is this true?). If so, p3d must be equal to 'n' (the TSP number of cities parameter), but it is empty! And that's why the example is not functional still. Any ideas on how this can be resolved?

Also, the weird part is, if p3d is infact empty, then the extra 'n' cones must not be accounted for in the size of A = problem_data.data['A']. But, the whole problem started from there. A.shape[0] = 14462 while cone_len(cone) = 14402 (without including the 'z' counts). I checked for multiple values of 'n' and observed that cone_len(cone) is always less than A.shape[0] by 'n'

The examples do not run properly

I installed python 3.5, cvxpy 0.4, scsprox and ncvx 0.1.8 as the README said, but all the examples show errors.
Also, the NCVX supported functions do not work well, such as integer(n, M).
Is there anything wrong with the versions of installed modules?
Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.