Python Forum
How to use scipy.optimization.brute for multivariable function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use scipy.optimization.brute for multivariable function
#3
(Oct-19-2020, 10:08 PM)scidam Wrote: You need to define ranges where brute will search for an optimum, e.g.

grid = ((-1, 1, 0.1), (-1, 1, 0.1)) 
# Also, you can use slice objects for this:
# grid = (slice(-1, 1, 0.1), slice(-1, 1, 0.1))
Further, you need to define a function to be optimized:

def f(x, T):
    return (x[0] - T) ** 2 + (x[1] - T) ** 2
And, finally, use brute to find the minimum:

from scipy.optimize import brute
brute(f, grid, (1,))

Thanks a lot for your kind reply.


And I have a question-
brute(f, grid, (1,))
What does "(1,)" stand for? Is it the value of parameter 'T'?

And when defined the function, you used x[0] and x[1]; why?
Mathematically the function is 'f(x,y,T)=(x - T)^2 + (y - T)^2.
Am I right?
Reply


Messages In This Thread
RE: How to use scipy.optimization.brute for multivariable function - by Shiladitya - Oct-20-2020, 09:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Minimize function with SciPy PierreLCV 3 379 Apr-05-2024, 07:51 AM
Last Post: paul18fr
  Need an alternative to brute force optimization loop jmbonni 5 1,228 Dec-07-2023, 12:28 PM
Last Post: RockBlok
  Solving an equation by brute force within a range alexfrol86 3 2,857 Aug-09-2022, 09:44 AM
Last Post: Gribouillis
  Optimization using scipy.optimize KaneBilliot 3 1,930 Nov-30-2021, 08:03 AM
Last Post: Gribouillis
  I need advise with developing a brute forcing script fatjuicypython 11 5,170 Aug-21-2020, 09:20 PM
Last Post: Marbelous
  ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package AaronKR 1 10,348 Jul-09-2020, 02:36 AM
Last Post: bowlofred
  Password Brute Force 2skywalkers 9 5,440 Oct-18-2018, 02:35 PM
Last Post: buran
  Brute Force Password Guesser 2skywalkers 1 3,209 Oct-05-2018, 08:04 PM
Last Post: ichabod801
  Brute Force Pad Lock Guesser RedSkeleton007 4 3,991 Mar-03-2018, 07:42 AM
Last Post: RedSkeleton007
  Speeding up Brute force password guesser Gamervote 5 6,898 Jul-20-2017, 02:52 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020