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

  • Thread starter Thread starter dacruick
  • Start date Start date
  • Tags Tags
    Python
Click For Summary
The discussion centers on optimizing a function with multiple variables in Python, specifically using the SciPy library. The user encounters a TypeError indicating that the function's arguments must be a sequence. The function defined, `optimizefunction`, takes three parameters but is only provided with one when called. To resolve the error, it's essential to pass the additional variables correctly as a sequence, typically using a tuple. The correct usage of `scipy.optimize.fmin` requires ensuring that all parameters are included in the optimization call. This highlights the importance of understanding function argument handling in Python when performing multi-variable optimization.
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))
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 11 ·
Replies
11
Views
933
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
64
Views
9K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
3K