Directory of Open Source for Quantitative Finance and Trading
Username: Password: Not registered?
 
Quick Search:    (AJAX based: No need to press button)

Main : Excel : 


Category: Excel View Full Details
Download Now!Function Minimization using Nelder Mead Simplex
Submitter: vanna Date: 2008/12/31
Description:
This class is used for minimzing a user defined function in a module file. It uses Nelder mead simplex algorithm

For example, consider mimizing this function:
Public Function MyFunction(xVec As Variant) As Double
  MyFunction = (xVec(1, 1) - 4) ^ 2 + (xVec(2, 1) - 2.7) ^ 4 + (xVec(3, 1) - 6.7) ^ 4
End Function


Use the following code to get minimum:
ReDim initParams(1 To 3, 1 To 1)
initParams(1, 1) = 0
initParams(2, 1) = -1
initParams(3, 1) = -2.8
Dim nelderObj As New Nelder
result = nelderObj.SolveMaximum("MyFunction", initParams)


Optionally, accuracy or tolerance for convergence can be changed by setting eg., nelderObj.Tolerance_=0.00001


Demo for using this function

Got a question or problem with this link? Just enter your message and click on submit. No registration is required.

Note: A copy of this message will also be emailed to the submitter of this link
Downloaded 2367 times  2367  File Size 0 bytes  Supported Platforms Excel VBA  Home Page http://www.quantcode.com/
Rating: 9.00 (2 votes)
Rate this File | Modify | Delete | Report Broken File | Tell a Friend | Comments (40)

Poster Thread
azad2
Posted: 2009/12/13 3:46  Updated: 2009/12/13 3:46
Just popping in
Joined: 2009/12/12
From:
Posts: 5
 Re: Function Minimization using Nelder Mead Simplex
Hi
Will you please let me know how to apply this simplex in vba excel , many thanks.

Poster Thread
azad2
Posted: 2009/12/13 3:59  Updated: 2009/12/13 3:59
Just popping in
Joined: 2009/12/12
From:
Posts: 5
 Re: Function Minimization using Nelder Mead Simplex
Hi
I would you please explain how to display the results into the sheet. many thanks

Poster Thread
vanna
Posted: 2009/12/13 12:42  Updated: 2009/12/13 12:43
Just can't stay away
Joined: 2007/3/21
From:
Posts: 104
 Re: Function Minimization using Nelder Mead Simplex
when you run the function, it returns result array.

To display it in excel, simply refere it like
sheets("sheet1").range("a1").Value=result(1,1)
sheets("sheet1").range("a2").Value=result(2,1)
sheets("sheet1").range("a3").Value=result(3,1)

Poster Thread
azad2
Posted: 2010/1/5 17:23  Updated: 2010/1/5 17:23
Just popping in
Joined: 2009/12/12
From:
Posts: 5
 Re: Function Minimization using Nelder Mead Simplex
Hi
I need the VB codes for Particle Swarm Optimization(PSO) algorithm. Thanks

Poster Thread
azad2
Posted: 2010/10/6 17:22  Updated: 2010/10/6 17:22
Just popping in
Joined: 2009/12/12
From:
Posts: 5
 Re: Function Minimization using Nelder Mead Simplex
I have a rather complicated function to minimize , the number of variable is 6 ( three of them the values are constrained between (0-1), the other three are constrained (0-360) . I found that Nelder Mead simplex is not handling two different types of variables . Can I specify two types of variable within the Nelder Mead class ? for example X(1,1),X(2,1),X(3,1) & Y(1,1),Y(2,1),Y(3,1) . Thanks very much for your assistance.

Poster Thread
Anonymous
Posted: 2011/6/2 11:55  Updated: 2011/6/2 11:55
 Function Minimization using Nelder Mead Simplex
Hi
Can I use the Nelder Mead to optimize two functions? The first one is the main objective Function and the second one is an inter-loop inside the first function.

Poster Thread
Anonymous
Posted: 2011/6/24 9:55  Updated: 2011/6/26 13:40
 Function Minimization using Nelder Mead Simplex
Hi azad2. I have a simialr problem as you. Did you find a solution to your problem? Regards Elisabeth

Poster Thread
Anonymous
Posted: 2012/8/29 3:17  Updated: 2012/9/16 21:32
 Function Minimization using Nelder Mead Simplex
How to solve for the function f(x,y)= logx - x^2?

Poster Thread
Anonymous
Posted: 2012/12/4 17:28  Updated: 2012/12/14 22:23
 Function Minimization using Nelder Mead Simplex
Can I know what algorithm you have used in the Nelder-Mead Simplex?

Discuss this file. Just enter your message and click on submit. No registration is required.
Similar Links:
Levenberg Marquardt for function minimization (Forum)
Tutorial and code for Constrained function minimization (Software)
Demo for minimizing function with Adaptive Simulated Annealing (ASA) (Software)
Bilinear interpolation function in VBA (Software)
Bilinear interpolation function for GSL (Software)

Subscribe to RSS or daily email updates of latest quantitative finance code listings
Email address :
Copyright © 2011 QuantCode Inc. All rights reserved.