Closed joyo44 closed 2 months ago
Ah, I see. If you put np.diff(chords) <= 0 in square brackets, it should work. Like this:
opti.subject_to(
[np.diff(chords) <= 0]
)
Hope that helps! Let me know if it doesn't work and I'll debug it with ya.
Hi @joyo44,
This traceback says that you have attempted to apply np.diff()
to a list, rather than an array-like object. To fix this, first convert the object you're trying to evaluate to an array-like object:
import aerosandbox.numpy
...
opti.subject_to(
np.diff(np.array(chords)) <= 0
)
Trying to prevent increasing chord lengths spanwise during optimization with
opti.subject_to( np.diff(chords) <= 0 )
results in this error meassage from casadi:
*Traceback (most recent call last): np.diff(chords) <= 0 ^^^^^^^^^^^^^^^ File "C:\Users\LENOVO\anaconda3\envs\asb3\Lib\site-packages\aerosandbox\numpy\calculus.py", line 29, in diff result = _cas.diff(a) ^^^^^^^^^^^^ File "C:\Users\LENOVO\anaconda3\envs\asb3\Lib\site-packages\casadi\casadi.py", line 37257, in diff return _casadi.diff(args) ^^^^^^^^^^^^^^^^^^^ NotImplementedError: Wrong number or type of arguments for overloaded function 'diff'. Possible prototypes are: diff(DM,int,int) diff(SX,int,int) diff(MX,int,int) You have: '([MX])'**
chords = [MX(opti0_x_7), MX((opti0_x_7*opti0_x_6))]
AeroSandbox 4.2.3 Python 3.11.8