Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To constrain bounded arguments of the objective in Scipy minimize using the TNC method, you can use the bounds parameter of the minimize function. Here's an example code snippet:

from scipy.optimize import minimize

# define your objective function here
def objective(x):
    # your objective function code here

# define your bounds here
bounds = [(0, 1), (2, 5), (-10, 10)]  # example bounds

# call the minimize function with the TNC method and bounds parameter
result = minimize(objective, x0, method='TNC', bounds=bounds)

# the result object contains the solution, success status, etc.
print(result)

In the bounds list, each element corresponds to a variable in the objective function. The element is a tuple with two values, the lower and upper bounds for that variable. If you don't want to constrain a variable, you can use None as the lower or upper bound value.