PKU-MACDLab/IMPC-DR

CVXPY error while running `test.py`

Closed this issue · 6 comments

Hi,

I tried running test.py by specifying a few parameters as the following:


import      SET
import      datetime
from        run          import *
from        others   import *
import      numpy        as np
import pickle
import copy

def data_capture(a, b, c):
    data = {
        'pos_list': copy.copy(a),
        'position_list': copy.copy(b),
        'terminal_index_list': copy.copy(c)
    }
    return data

def initialize():
    agent_list=[]
    for i in range(SET.Num):
        agent_list+=[ uav(i,SET.ini_x[i],SET.ini_v[i],SET.target[i],SET.K) ]

    return agent_list

def PLAN( Num, ini_x, ini_v,target,r_min,epsilon,h,K,episodes):


    
    SET.initialize_set(Num, ini_x , ini_v ,target,r_min,epsilon ,h ,K,episodes)

    obj = {}

    ReachGoal=False

    episodes=SET.episodes
    
    agent_list=initialize()

    collect_data(agent_list)

    obj[0] = data_capture(SET.pos_list, SET.position_list, SET.terminal_index_list)

    # the main loop
    start =datetime.datetime.now()
    end = start

    for i in range(1,episodes+1):
        end_last=end


        obstacle_list=get_obstacle_list(agent_list,SET.Num)

        # run one step
        agent_list = run_one_step(agent_list,obstacle_list)

        # print
        end = datetime.datetime.now()
        print("Step %s have finished, running time is %s"%(i,end-end_last))

        collect_data(agent_list)

        obj[i] = data_capture(SET.pos_list, SET.position_list, SET.terminal_index_list)

        if ReachGoal:
            break

        ReachGoal=check_reach_target(agent_list)

        
        

    obj['goal'] = SET.target

    return obj,agent_list


if __name__ == "__main__":
    
    Num = 3
    ini_x = [[0 ,0, 0],[2.0, 2.0, 2.0],[-1.5,1.6,1.8]]
    ini_v = [[0.01, 0, 0.01], [0, 0, 0], [0, 0, 0]]
    target = [[1.2, 1.3, 0.6],[ -0.4, -0.6, 1.1], [1.5, -1.5, 0.55]]
    K=15
    h = 0.1
    episodes = 20
    r_min = 0.3
    epsilon= 0.1
    
    obj, agents_list = PLAN(Num, ini_x, ini_v,target,r_min,epsilon,h,K,episodes)
    
    print(f'Obj is :{obj}\n')
    print(f' Agent_list is {agents_list}')
    
    

    

However, the following error occurred:

Traceback (most recent call last):
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/linalg.py", line 113, in is_psd_within_tol
    ev = SA_eigsh(-tol)  # might return np.NaN, or raise exception
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/linalg.py", line 97, in SA_eigsh
    return sparla.eigsh(A, k=1, sigma=sigma, which='SA', v0=v0,
  File "/home/randychen233/.local/lib/python3.10/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 1697, in eigsh
    params.iterate()
  File "/home/randychen233/.local/lib/python3.10/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 571, in iterate
    self._raise_no_convergence()
  File "/home/randychen233/.local/lib/python3.10/site-packages/scipy/sparse/linalg/_eigen/arpack/arpack.py", line 377, in _raise_no_convergence
    raise ArpackNoConvergence(msg % (num_iter, k_ok, self.k), ev, vec)
scipy.sparse.linalg._eigen.arpack.arpack.ArpackNoConvergence: ARPACK error -1: No convergence (451 iterations, 0/1 eigenvectors converged)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/test.py", line 88, in <module>
    obj, agents_list = PLAN(Num, ini_x, ini_v,target,r_min,epsilon,h,K,episodes)
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/test.py", line 53, in PLAN
    agent_list = run_one_step(agent_list,obstacle_list)
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/run.py", line 50, in run_one_step
    agent_list=[run_one_agent(items[i]) for i in range(SET.Num)]
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/run.py", line 50, in <listcomp>
    agent_list=[run_one_agent(items[i]) for i in range(SET.Num)]
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/run.py", line 69, in run_one_agent
    agent.cache=run_cvxp(agent)
  File "/home/randychen233/projects/ICON_lab/IMPC-DR/3D/run.py", line 142, in run_cvxp
    prob.solve()
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 503, in solve
    return solve_func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 1072, in _solve
    data, solving_chain, inverse_data = self.get_problem_data(
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 646, in get_problem_data
    solving_chain = self._construct_chain(
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 898, in _construct_chain
    return construct_solving_chain(self, candidate_solvers, gp=gp,
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/reductions/solvers/solving_chain.py", line 217, in construct_solving_chain
    reductions = _reductions_for_problem_class(problem, candidates, gp, solver_opts)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/reductions/solvers/solving_chain.py", line 124, in _reductions_for_problem_class
    if not gp and not problem.is_dcp():
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/performance_utils.py", line 73, in _compute_once
    result = func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 257, in is_dcp
    return all(
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/problem.py", line 258, in <genexpr>
    expr.is_dcp(dpp) for expr in self.constraints + [self.objective])
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/problems/objective.py", line 153, in is_dcp
    return self.args[0].is_convex()
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/performance_utils.py", line 73, in _compute_once
    result = func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/atoms/atom.py", line 178, in is_convex
    if not (arg.is_affine() or
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/performance_utils.py", line 73, in _compute_once
    result = func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/expressions/expression.py", line 221, in is_affine
    return self.is_constant() or (self.is_convex() and self.is_concave())
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/performance_utils.py", line 73, in _compute_once
    result = func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/atoms/atom.py", line 176, in is_convex
    elif self.is_atom_convex():
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/atoms/quad_form.py", line 69, in is_atom_convex
    return P.is_constant() and P.is_psd()
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/performance_utils.py", line 73, in _compute_once
    result = func(self, *args, **kwargs)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/expressions/constants/constant.py", line 227, in is_psd
    self._psd_test = eig_util.is_psd_within_tol(self.value, s.EIGVAL_TOL)
  File "/home/randychen233/.local/lib/python3.10/site-packages/cvxpy/utilities/linalg.py", line 129, in is_psd_within_tol
    raise sparla.ArpackNoConvergence(error_with_note, e.eigenvalues, e.eigenvectors)
scipy.sparse.linalg._eigen.arpack.arpack.ArpackNoConvergence: ARPACK error -1: ARPACK error -1: No convergence (451 iterations, 0/1 eigenvectors converged)


        CVXPY note: This failure was encountered while trying to certify
        that a matrix is positive semi-definite (see [1] for a definition).
        In rare cases, this method fails for numerical reasons even when the matrix is
        positive semi-definite. If you know that you're in that situation, you can
        replace the matrix A by cvxpy.psd_wrap(A).

        [1] https://en.wikipedia.org/wiki/Definite_matrix

I wonder what would be causing CVXPY to fail here?

@RandyChen233 Have you successfully run CVXPY in WSL before make any modification?

@CYDXYYJ Hi,

Yes, I have been using CVXPY for a while in WSL, and I have not made any modifications.

@RandyChen233 Ok, I'll test your code in this weekend and give you a response in the next week.

Thank you ! @CYDXYYJ I also have a question about the distributed nature of the algorithm, and I wonder if you could clarify it: should each agent i only receives position information from its one-hop neighbor j to compute its buffered Voronoi cell? or should agent i considers all other agents j that is in the configuration space?

@RandyChen233 Agent i only need to communicate with the otehrs in a finite rage. This property can be found in paper which can be found in arxiv. If you have any other questions, you can contact with me via e-mail which can be found in my Github profile.

@RandyChen233 I have tested your code, you'd better change it as

ini_x = np.array([[0 ,0, 0],[2.0, 2.0, 2.0],[-1.5,1.6,1.8]]) 
ini_v = np.array([[0.01, 0, 0.01], [0, 0, 0], [0, 0, 0]])
target = np.array([[1.2, 1.3, 0.6],[ -0.4, -0.6, 1.1], [1.5, -1.5, 0.55]])