Ask Your Question

Revision history [back]

The problem is that f is a symbolic expression (like a formula, which is good to compute derivatives), not a function (that can be called). You can

You can transform a symbolic expression into a callable function with fast_callable:

optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+fast_callable(f)(X[i]))

The problem is that f is a symbolic expression (like a formula, which is good to compute derivatives), not a function (that that can be called). You can called to transform floating-point numbers into floating-point numbers (it will instead return a symbolic expression).

You can transform a symbolic expression into a callable function with fast_callable:

optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+fast_callable(f)(X[i]))

The problem is that f is a symbolic expression (like a formula, which is good to compute derivatives), not a function that can be called to transform floating-point numbers into floating-point numbers (it will instead return a symbolic expression).

You can transform a symbolic expression into a callable function defined on the floating-point numbers with fast_callablefast_float:

optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+fast_callable(f)(X[i]))
optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+fast_float(f)(X[i]))