Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

minimization without constraints gives error for multiple dimension

I'm trying to use minimize(func, x0, gradient=None, hessian=None, algorithm='default', verbose=False, **args) given the gradient function. But I'm getting the following error:

sage: f = lambda x : (x*y)**4
sage: g = lambda x : 4*y*(x*y)**4
sage: y = random_vector(RR, 5)
sage: x = random_vector(RR,5)
sage: minimize(f, x, gradient=g)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

What am I doing wrong? the gradient return a vector (correctly so). Shouldn't this work?

minimization without constraints gives error for multiple dimension

I'm trying to use minimize(func, x0, gradient=None, hessian=None, algorithm='default', verbose=False, **args) given the gradient function. But I'm getting the following error:

sage: f = lambda x : (x*y)**4
sage: g = lambda x : 4*y*(x*y)**4
4*y*(x*y)**3
sage: y = random_vector(RR, 5)
sage: x = random_vector(RR,5)
sage: minimize(f, x, gradient=g)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

What am I doing wrong? the gradient return a vector (correctly so). Shouldn't this work?