Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran Minimization with Changing parameters

Status
Not open for further replies.

semiter

Programmer
Feb 22, 2011
3
US
Hi All,

How can I minimize a function with varying parameters?

For example: f(x;a) is a function of x with parameter a, but a is updated each time I minimize f.
That is, given first a (a0), I minimize f, and I update a to a1 based on the first minimization. And then given a1, I minimize f again, and so on.

Is there any minimization subroutine can minimize f with this sort of changing parameters? I know matlab can do this easily by choosing which variable to minimize with other parameters given, but how this can be implemented in Fortran?

Thanks in advance!!
Jun
 
This is more a mathematical problem than a fortran problem. The right thing to do is minimisation along a vector making "a" part of x, say: vectorX=(x,a) anf f=f(vectorX)

Once, defined like that, there's a huge amount of possibilities. Gradient based, simplex or even genetic, although I wouldn't use that last one. You also have to make a difference between looking for f(x,a)=0 or looking for the minimum of f(x,a).

Please look in "numerical recipes in fortran 77" which is freely available online, they don't only give good routines, they even give a source (which I would rewrite in F90).

Before programming anything in fortran you should look at the physics behind your problem to decide about the right method
 
Thank you, GerritGroot!!

I agree that I can make "a" and "x" together as a vector "X". But the question is that finally I am not going to minimize a two-dimensional function. Instead, I am going to fix "a" and maximize along the dimension of x. So this problem is more or less like a constrained minimization problem, with "a" fixed as some value in each iteration.

 
Ok, maybe I understood you wrong about what you mean by iteration. If "iteration" is one minimisation loop only, then "a" should be a parameter (if not, it will never converge), but if you mean by "iteration" some proces that covers a bunch of minimisation loops "a" can be fixed. In the book I mentioned before you can also find 1D minimisation. A quite stable, but maybe not the fastest one, is the bracketing+goldensection combination.
 
Thanks!!

I actually found out how to solve this problem I had. It is to pass the global "a" into the function. I am new in programming, so I thought only constant can be global in Fortran.

My question is in the area of optimization. Often one needs to find the desired "a". You start by guessing an "a", and maximize the f(x;a) using the guessed "a", and then use the optimized "f" to update "a", and then optimize again, and keep going like this, until "a" converge to some tolerance level.

Again, thank you, GerritGroot! I really appreciate!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top