Can Python scipy.optimize.fmin() Optimize More Than One Variable at Once?

  • Context: Python 
  • Thread starter Thread starter dacruick
  • Start date Start date
  • Tags Tags
    Python
Click For Summary
SUMMARY

The forum discussion centers on the use of Python's scipy.optimize.fmin() function for optimizing multiple variables simultaneously. The user encounters a TypeError indicating that the function's arguments must be passed as a sequence. The correct implementation requires the optimization function to accept a single sequence of variables rather than multiple separate arguments. The solution involves modifying the function definition and the way arguments are passed to ensure compatibility with scipy.optimize.fmin().

PREREQUISITES
  • Understanding of Python programming and function definitions
  • Familiarity with the SciPy library, specifically scipy.optimize
  • Knowledge of optimization concepts and techniques
  • Experience with handling variable arguments in Python functions
NEXT STEPS
  • Review the documentation for scipy.optimize.fmin() to understand its parameters and usage
  • Learn about defining functions that accept variable-length arguments in Python
  • Explore alternative optimization functions in SciPy, such as scipy.optimize.minimize()
  • Investigate best practices for debugging TypeErrors in Python
USEFUL FOR

Python developers, data scientists, and anyone interested in optimizing functions with multiple variables using the SciPy library.

dacruick
Messages
1,038
Reaction score
1
Hi All,

I am trying to optimize for more than 1 variable at the same time. is that possible?
 
Technology news on Phys.org
I am trying to use this properly but I keep getting the same error.

TypeError: optimizefunction() argument after * must be a sequence

def optimizefunction(x,y,z):
x=5

return abs(x-y*z)

print scipy.optimize.fmin(optimizefunction, 2, (y,z))
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
Replies
64
Views
11K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K