Ask Your Question
1

What is the method for constraining bounded args of the objective in Scipy minimize using the TNC method?

asked 2023-06-22 08:11:20 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-22 08:29:01 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-22 08:11:20 +0000

Seen: 7 times

Last updated: Jun 22 '23