esa / pykep

PyKEP is a scientific library providing basic tools for research in interplanetary trajectory design.
http://esa.github.io/pykep/
GNU General Public License v3.0
339 stars 96 forks source link

error when running examples with pygmo and SNOPT7 #81

Closed Guanli20131 closed 5 years ago

Guanli20131 commented 6 years ago

when I use snopt7 by running pygmo examples or pykep examples, I got ValueError: in code "pop = algo.evolve(pop)", but there is no problem when I run examples 1 and 2 in pykep. My Computer : Widows10 64bit Python3.6 64bit, with these libs intalled :

matplotlib 3.0.0 numpy 1.15.2 pygmo 2.4 pygmo-plugins-nonfree 0.4 pykep 2.2 pyopt 0.84 scipy 1.1.0

I got a snopt libs and license from Standford's website, also the FORTAN and SNOPT_C interface libraries ,and copy them to "C:\Python\SnoptLib\". They are "snopt7.dll, snopt7.lib, snopt7.lic, snopt7_c.dll, snopt7_c.lib".

The Test code is from pygmo examples or pykep, such as: from pygmo import from pygmo_plugins_nonfree import snopt7 algo = algorithm(snopt7(screen_output = False, library = r"C:\Python\SnoptLib\snopt7_c.dll")) algo.set_verbosity(1) prob = problem(cec2006(prob_id = 1)) prob.c_tol = [1e-6]9 pop = population(prob, 1) pop = algo.evolve(pop)


ValueError Traceback (most recent call last)

in 6 prob.c_tol = [1e-6]*9 7 pop = population(prob, 1) ----> 8 pop = algo.evolve(pop) ValueError: when the SQP method is modified to NLOPT, there is no problem. So where is the trouble? Thank you for your answer.
darioizzo commented 6 years ago

Can you post the error message? Value error what?

On Sun, 21 Oct 2018, 15:03 Guanli20131, notifications@github.com wrote:

when I use snopt7 by running pygmo examples or pykep examples, I got ValueError: in code "pop = algo.evolve(pop)", but there is no problem when I run examples 1 and 2 in pykep. My Computer : Widows10 64bit Python3.6 64bit, with these libs intalled :

matplotlib 3.0.0 numpy 1.15.2 pygmo 2.4 pygmo-plugins-nonfree 0.4 pykep 2.2 pyopt 0.84 scipy 1.1.0

I got a snopt libs and license from Standford's website, also the FORTAN and SNOPT_C interface libraries ,and copy them to "C:\Python\SnoptLib". They are "snopt7.dll, snopt7.lib, snopt7.lic, snopt7_c.dll, snopt7_c.lib".

The Test code is from pygmo examples or pykep, such as: from pygmo import from pygmo_plugins_nonfree import snopt7 algo = algorithm(snopt7(screen_output = False, library = r"C:\Python\SnoptLib\snopt7_c.dll")) algo.set_verbosity(1) prob = problem(cec2006(prob_id = 1)) prob.c_tol = [1e-6]9 pop = population(prob, 1) pop = algo.evolve(pop)

ValueError Traceback (most recent call last) in 6 prob.c_tol = [1e-6]*9 7 pop = population(prob, 1) ----> 8 pop = algo.evolve(pop) ValueError:

when the SQP method is modified to NLOPT, there is no problem. So where is the trouble? Thank you for your answer.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/esa/pykep/issues/81, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLEb3PxQyxkYcvPakgumI6Du5mJbS6-ks5unHCjgaJpZM4Xyct- .

Guanli20131 commented 6 years ago

By running example 8 in PyKep with IPython, I got message below:

In [1]: import pykep as pk
In [2]: pk.examples.run_example8()

ValueError                                Traceback (most recent call last)
<ipython-input-2-a755e5a01f4e> in <module>
----> 1 pk.examples.run_example8()
c:\python\python36\lib\site-packages\pykep\examples\_ex8.py in run_example8(nseg)
     35
     36     # 4 - Solve the problem (evolve)
---> 37     pop = algo.evolve(pop)
     38
     39     # 5 - Inspect the solution
ValueError:
In [3]:

There is no other message any more. When the row algo = algo_factory("snopt7") in example 8 was modified to algo = algo_factory("slsqp") , there is no error message displayed, and I got the right result after a short period running.

This is the parametre value when I run example 8 in Pycharm IDE, I do not know whether it is useful for you to position the problem.

axis = {AxesSubplot} AxesSubplot(0.125,0.11;0.775x0.77)
nseg = {int} 40
pop = {population} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>
    Global dimension:            129
    Integer dimension:           0
    Fitness dimension:           50
    Number of objectives:      1
    Equality constraints dimension:7
    Inequality constraints dimension:    42\
    Tolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]
    Lower bounds: [1100, 200, 100, -3500, -3500, ... ]
    Upper bounds: [1400, 750, 1000, 3500, 3500, ... ]

    Has gradient: true
    User implemented gradient sparsity: false
    Expected gradients: 6450
    Has hessians: false
    User implemented hessians sparsity: false

    Fitness evaluations: 23042
    Gradient evaluations: 16068

    Thread safety: none

    Population size: 1

    List of individuals:
#0:
    ID:\t\t\t14259131561737751408
    Decision vector:    [1286.56, 665.77, 905.563, 3247.08, 1258.91, ... ]
    Fitness vector:    [-905.563, -7.40042e-008, -7.65504e-008, 4.63234e-009, 4.18154e-008, ... ]

    Champion decision vector: [1286.56, 665.77, 905.563, 3247.08, 1258.91, ... ]
    Champion fitness: [-...
 champion_f = {ndarray}  
 champion_x = {ndarray}  
 problem = {problem} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]\n\tLower bounds: [1100, 200, 100, -3500, -3500, ... ]\n\tUpper bounds: [1400, 750, 1000, 3500, 3500, ... ]\n\n\tHas gradient: true\n\tUser implemented gradient sparsity: false\n\tExpected gradients: 6450\n\tHas hessians: false\n\tUser implemented hessians sparsity: false\n\n\tFitness evaluations: 23042\n\tGradient evaluations: 16068\n\n\tThread safety: none\n
prob = {problem} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]\n\tLower bounds: [1100, 200, 100, -3500, -3500, ... ]\n\tUpper bounds: [1400, 750, 1000, 3500, 3500, ... ]\n\n\tHas gradient: true\n\tUser implemented gradient sparsity: false\n\tExpected gradients: 6450\n\tHas hessians: false\n\tUser implemented hessians sparsity: false\n\n\tFitness evaluations: 1\n\tGradient evaluations: 0\n\n\tThread safety: none\n
 c_tol = {ndarray}  
udp = {add_gradient} <pykep.examples._ex_utilities.add_gradient object at 0x00000230BB04DC18>
 prob = {problem} Problem name: <class 'pykep.trajopt._direct.direct_pl2pl'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constra
 udp_inner = {direct_pl2pl} <pykep.trajopt._direct.direct_pl2pl object at 0x00000230BB04D7B8>
 with_grad = {bool} True 

Thank you for your answer.

darioizzo commented 6 years ago

most likely your snopt7 dll is missing some symbols.

On Mon, 22 Oct 2018 at 16:31 Guanli20131 notifications@github.com wrote:

By running example 8 in PyKep with IPython, I got message below:

In [1]: import pykep as pk In [2]: pk.examples.run_example8() ValueError Traceback (most recent call last) in ----> 1 pk.examples.run_example8() c:\python\python36\lib\site-packages\pykep\examples_ex8.py in run_example8(nseg) 35 36 # 4 - Solve the problem (evolve) ---> 37 pop = algo.evolve(pop) 38 39 # 5 - Inspect the solution ValueError: In [3]:

There is no other message any more. When the row "algo = algo_factory("snopt7")" in example 8 was modified to "algo = algo_factory("slsqp")" , there is no error message displayed, and I got the right result after a short period running. This is the parametre value when I run example 8 in Pycharm IDE, I do not know whether it is useful for you to position the problem. axis = {AxesSubplot} AxesSubplot(0.125,0.11;0.775x0.77) nseg = {int} 40 pop = {population} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]\n\tLower bounds: [1100, 200, 100, -3500, -3500, ... ]\n\tUpper bounds: [1400, 750, 1000, 3500, 3500, ... ]\n\n\tHas gradient: true\n\tUser implemented gradient sparsity: false\n\tExpected gradients: 6450\n\tHas hessians: false\n\tUser implemented hessians sparsity: false\n\n\tFitness evaluations: 23042\n\tGradient evaluations: 16068\n\n\tThread safety: none\n\nPopulation size: 1\n\nList of individuals: \n#0:\n\tID:\t\t\t14259131561737751408\n\tDecision vector:\t[1286.56, 665.77, 905.563, 3247.08, 1258.91, ... ]\n\tFitness vector:\t\t[-905.563, -7.40042e-008, -7.65504e-008, 4.63234e-009, 4.18154e-008, ... ]\n\nChampion decision vector: [1286.56, 665.77, 905.563, 3247.08, 1258.91, ... ]\nChampion fitness: [-... champion_f = {ndarray} champion_x = {ndarray} problem = {problem} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]\n\tLower bounds: [1100, 200, 100, -3500, -3500, ... ]\n\tUpper bounds: [1400, 750, 1000, 3500, 3500, ... ]\n\n\tHas gradient: true\n\tUser implemented gradient sparsity: false\n\tExpected gradients: 6450\n\tHas hessians: false\n\tUser implemented hessians sparsity: false\n\n\tFitness evaluations: 23042\n\tGradient evaluations: 16068\n\n\tThread safety: none\n prob = {problem} Problem name: <class 'pykep.examples._ex_utilities.add_gradient'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constraints: [1e-005, 1e-005, 1e-005, 1e-005, 1e-005, ... ]\n\tLower bounds: [1100, 200, 100, -3500, -3500, ... ]\n\tUpper bounds: [1400, 750, 1000, 3500, 3500, ... ]\n\n\tHas gradient: true\n\tUser implemented gradient sparsity: false\n\tExpected gradients: 6450\n\tHas hessians: false\n\tUser implemented hessians sparsity: false\n\n\tFitness evaluations: 1\n\tGradient evaluations: 0\n\n\tThread safety: none\n c_tol = {ndarray} udp = {add_gradient} <pykep.examples._ex_utilities.add_gradient object at 0x00000230BB04DC18> prob = {problem} Problem name: <class 'pykep.trajopt._direct.direct_pl2pl'>\n\tGlobal dimension:\t\t\t129\n\tInteger dimension:\t\t\t0\n\tFitness dimension:\t\t\t50\n\tNumber of objectives:\t\t\t1\n\tEquality constraints dimension:\t\t7\n\tInequality constraints dimension:\t42\n\tTolerances on constra udp_inner = {direct_pl2pl} <pykep.trajopt._direct.direct_pl2pl object at 0x00000230BB04D7B8> with_grad = {bool} True

Thank you for your answer.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/esa/pykep/issues/81#issuecomment-431852543, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLEb0C3yoRMlZfqlDNwEw9KGwcygKFyks5undaygaJpZM4Xyct- .

Guanli20131 commented 6 years ago

ohh,what can I do to fix it?

darioizzo commented 5 years ago

Will close this as its a snopt7 compilation issue. pykep pygmo work and are tested with the official snopt 7 libraries