Greetings everyone.
I am trying to use the scipy.optimize.minimize func inside GH using the Remote component but it fails. Here’s the python code for quick reference . The problem that I can’t seem to figure out is how can the matplotlib.pyplot module work but when i attempt to load the scipy.optimize module it doesn’t work? How can I make it work? I have used the conda install scipy in the rhinoremote environment as well as the
ghpyremote_import_scipy_module_error.gh (16.7 KB)
import scriptcontext
import rhinoscriptsyntax as rs
np = scriptcontext.sticky['numpy']
mpl = scriptcontext.sticky['matplotlib']
plt = mpl.pyplot #How come the pyplot extension is succesfully imported but scipy isnt
arr = np.linspace(-1,1,25)
plt.plot(-arr, np.sin(arr), c = 'r')
plt.plot(np.tan(arr), -arr[::-1], c='orange')
plt.show()
#scipy import
scipy = scriptcontext.sticky['scipy']
_minimize = scipy.optimize.minimize
#Objective function
s = 20000
l = 40000
def objective(arr):
x = arr[0]
y = arr[1]
w = arr[2]
o = arr[3]
return (o - w / 2) % x + (s - w) % x + (l - y - (o + (l-s)//s*s + w / 2)) % x
initial = [1500, 600, 1600, 6000]
bounds = [(1500,2100), (600, 2350),(1600,2600), (3000,15000)]
sol = _minimize(fun=objective, x0=initial, bounds=bounds, method='Nelder-Mead')
And Here is the error I get
Runtime error (Exception): 'module' object has no attribute 'optimize'
Traceback:
line 102, in value, "C:\Users\dgs\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\async_.py"
line 469, in sync_request, "C:\Users\dgs\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\protocol.py"
line 76, in syncreq, "C:\Users\dgs\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\netref.py"
line 161, in __getattribute__, "C:\Users\dgs\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\netref.py"
line 18, in script