spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.3k stars 1.61k forks source link

Spyder crashes when using pulp #12486

Closed Nosferuity closed 4 years ago

Nosferuity commented 4 years ago

Description

What steps will reproduce the problem?

executing the following code crashes spyder causing the kernel to need to be restartet. please find my pip freeze below

--------start python code

-- coding: utf-8 --

""" Created on Thu Apr 23 11:41:59 2020

@author: Frederik

TODO find better solver than standad. hot candidates are glpk or clp

"""

from pulp import LpMinimize, LpInteger,LpVariable,LpProblem,lpSum,LpStatus

abgewandelt nach time indext rcpsp/cpr von kone2013 et al.

A=["d0","1","2","3","4","5","de"]#Activities (IDS)

R=["LHU","Microscope","PR"]#machines B={"LHU":1,"Microscope":1,"PR":1}#amount of availiable machines

P=["Tips","L1","L2","L3"]#consumables C={"Tips":96,"L1":100,"L2":100,"L3":100}#initial stock of consumables (also maximum stock of consumables)

E=[["d0","de"]]#precedence conditions

list of (i,j) (activitie ids) where it is forced upon the schedule that i preceeds j

p={"d0":0,"1":20*100,"2":24,"3":36,"4":42,"5":15,"de":0}#process duration of an activitie

timeHorizon=min(sum(p.values()),24*60)#maximum 1 day, minimum sum of process durations. schedule infeasible if schedule duration exceeds 1 day

H=range(0,timeHorizon)

b={"d0":{"LHU":0,"Microscope":0,"PR":0}, "1":{"LHU":1,"Microscope":0,"PR":0},#maschinenverbräuche "2":{"LHU":1,"Microscope":0,"PR":0}, "3":{"LHU":1,"Microscope":0,"PR":1}, "4":{"LHU":0,"Microscope":1,"PR":0}, "5":{"LHU":0,"Microscope":1,"PR":0}, "de":{"LHU":0,"Microscope":0,"PR":0} }

cplus={ "d0":{"Tips":0,"L1":0,"L2":0,"L3":0}, "de":{"Tips":0,"L1":0,"L2":0,"L3":0}, "1":{"Tips":0,"L1":2,"L2":13,"L3":4},#Ressourcen produktion jeder activitie "2":{"Tips":0,"L1":10,"L2":0,"L3":0}, "3":{"Tips":60,"L1":0,"L2":50,"L3":23}, "4":{"Tips":0,"L1":1,"L2":40,"L3":20}, "5":{"Tips":0,"L1":5,"L2":3,"L3":0}}

cminus={ "d0":{"Tips":0,"L1":0,"L2":0,"L3":0},#Ressourcen verbrauch jeder activitie "de":{"Tips":0,"L1":0,"L2":0,"L3":0}, "1":{"Tips":0,"L1":2,"L2":13,"L3":4}, "2":{"Tips":60,"L1":10,"L2":0,"L3":0}, "3":{"Tips":0,"L1":0,"L2":50,"L3":23}, "4":{"Tips":60,"L1":1,"L2":40,"L3":20}, "5":{"Tips":0,"L1":5,"L2":3,"L3":0}}

prob = LpProblem("SCD_Schdeduling",LpMinimize)

S=LpVariable.dicts("S",A,0,None,LpInteger) x=LpVariable.dicts("x",(A,H),0,1,LpInteger) s=LpVariable.dicts("s",(H,P),0,None,LpInteger)

3 Objective

prob+=lpSum(t*x["de"][t] for t in H) #check

preset

prob+=x["d0"][0]==1#check

4

for (i,j) in E: prob+=lpSum(tx[j][t] for t in H)>=(lpSum(tx[i][t] for t in H)+p[i])#ergibt sinn #check

5

for k in R: for t in H: prob+=lpSum(b[i][k]*lpSum(x[i][tau] for tau in range(max(0,t-p[i]+1),min(timeHorizon,t)+1)) for i in A)<=B[k]#check

6

for i in A: prob+=lpSum(x[i][t] for t in H)==1#check

8

for roh in P: prob+=(C[roh]-lpSum(x[i][0]*cminus[i][roh] for i in A))

9

for t in H: if t>0: for roh in P: prob+=(s[t][roh]==s[t-1][roh]+lpSum(x[i][t-p[i]]cplus[i][roh] for i in A if t-p[i]>=0)-lpSum(x[i][t]cminus[i][roh] for i in A))

for t in H: for roh in P: prob+=s[t][roh]<=C[roh]#lager nicht überfüllen

recover S

for i in A: prob+=S[i]==lpSum(t*x[i][t] for t in H)

for i in A: prob+=S[i]<=S["de"] prob+=S[i]>=S["d0"]

for i in A: prob+=lpSum(t*x["de"][t] for t in H)>=S[i]+p[i]

prob.solve()

for v in prob.variables(): if("S" in v.name): print(v.name, "=", v.varValue) if(v.varValue!=0 and ("S" not in v.name and "s" not in v.name)): print(v.name, "=", v.varValue)

print("Status:", LpStatus[prob.status])

--------end python code (base) C:\Users\Frederik>conda activate ma

(ma) C:\Users\Frederik>pip freeze alabaster==0.7.12 argh==0.26.2 asn1crypto==1.3.0 astroid==2.3.3 atomicwrites==1.3.0 attrs==19.3.0 autopep8==1.4.4 Babel==2.8.0 backcall==0.1.0 bcrypt==3.1.7 bleach==3.1.0 certifi==2019.11.28 cffi==1.14.0 chardet==3.0.4 cloudpickle==1.3.0 colorama==0.4.3 cryptography==2.8 cycler==0.10.0 decorator==4.4.2 defusedxml==0.6.0 diff-match-patch==20181111 docutils==0.16 entrypoints==0.3 flake8==3.7.9 future==0.18.2 idna==2.9 imagesize==1.2.0 importlib-metadata==1.5.0 intervaltree==3.0.2 ipykernel==5.1.4 ipython==7.13.0 ipython-genutils==0.2.0 isort==4.3.21 jedi==0.15.2 Jinja2==2.11.1 joblib==0.14.1 jsonschema==3.2.0 jupyter-client==6.1.2 jupyter-core==4.6.3 keyring==21.1.1 kiwisolver==1.1.0 lazy-object-proxy==1.4.3 MarkupSafe==1.1.1 matplotlib==3.1.3 mccabe==0.6.1 mip==1.8.1 mistune==0.8.4 mkl-fft==1.0.15 mkl-random==1.1.0 mkl-service==2.3.0 more-itertools==8.2.0 nbconvert==5.6.1 nbformat==5.0.4 numpy==1.18.1 numpydoc==0.9.2 packaging==20.3 pandas==1.0.3 pandocfilters==1.4.2 paramiko==2.7.1 parso==0.5.2 pathtools==0.1.2 pexpect==4.8.0 pickleshare==0.7.5 plotly==4.5.2 pluggy==0.13.1 prompt-toolkit==3.0.4 psutil==5.7.0 PuLP==2.1 pycodestyle==2.5.0 pycparser==2.20 pydocstyle==4.0.1 pyflakes==2.1.1 Pygments==2.6.1 pylint==2.4.4 PyNaCl==1.3.0 pyOpenSSL==19.1.0 pyparsing==2.4.6 pyrsistent==0.16.0 PySocks==1.7.1 python-dateutil==2.8.1 python-jsonrpc-server==0.3.4 python-language-server==0.31.9 pytz==2019.3 pywin32==227 pywin32-ctypes==0.2.0 PyYAML==5.3.1 pyzmq==18.1.1 QDarkStyle==2.8 QtAwesome==0.7.0 qtconsole==4.7.2 QtPy==1.9.0 requests==2.23.0 retrying==1.3.3 rope==0.16.0 Rtree==0.9.3 scikit-learn==0.22.1 scipy==1.4.1 six==1.14.0 snowballstemmer==2.0.0 sortedcontainers==2.1.0 Sphinx==2.4.4 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.4 spyder==4.1.1 spyder-kernels==1.9.0 testpath==0.4.4 tornado==6.0.4 traitlets==4.3.3 ujson==1.35 urllib3==1.25.8 watchdog==0.10.2 wcwidth==0.1.9 webencodings==0.5.1 win-inet-pton==1.1.0 wincertstore==0.2 wrapt==1.12.1 yapf==0.28.0 zipp==2.2.0

Traceback

  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\_pswindows.py", line 933, in create_time
    user, system, created = cext.proc_times(self.pid)
ProcessLookupError: [Errno 3] No such process (originated from GetExitCodeProcess != STILL_ACTIVE)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\__init__.py", line 373, in _init
    self.create_time()
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\__init__.py", line 723, in create_time
    self._create_time = self._proc.create_time()
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=2440)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\qtconsole\manager.py", line 27, in poll
    super(QtKernelRestarter, self).poll()
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\jupyter_client\restarter.py", line 113, in poll
    self.kernel_manager.restart_kernel(now=True, newports=newports)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\jupyter_client\manager.py", line 411, in restart_kernel
    self.shutdown_kernel(now=now, restart=True)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\jupyter_client\manager.py", line 371, in shutdown_kernel
    self._kill_kernel()
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\spyder\plugins\ipythonconsole\utils\manager.py", line 78, in _kill_kernel
    self.kill_proc_tree(self.kernel.pid)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\spyder\plugins\ipythonconsole\utils\manager.py", line 44, in kill_proc_tree
    parent = psutil.Process(pid)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\__init__.py", line 346, in __init__
    self._init(pid)
  File "C:\Users\Frederik\.conda\envs\ma\lib\site-packages\psutil\__init__.py", line 386, in _init
    raise NoSuchProcess(pid, None, msg)
psutil.NoSuchProcess: psutil.NoSuchProcess no process found with pid 2440
WARNING:traitlets:kernel died: 45.01293683052063
WARNING:traitlets:kernel died: 45.0056848526001
WARNING:traitlets:kernel died: 45.014880895614624

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
paramiko >=2.4.0               :  2.7.1 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.7.0 (OK)
qtconsole >=4.6.0              :  4.7.2 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.3 (OK)
sphinx >=0.6.6                 :  2.4.4 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  18.1.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  3.1.3 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  1.0.3 (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  None (OK)
spyder-bot commented 4 years ago

Duplicate of #11872. It will be fixed in our next version (4.1.2)