3

I'm quite new to F# and have a problem. I want to solve a nonlinear, constrained optimization problem. The goal is to minimize a function minFunc with six parameters a, b, c, d, gamma and rho_infty, (the function is quite long so I don´t post it here) and the additional conditions:

a + d > 0,
d > 0,
c > 0,
gamma > 0,
0 <= gamma <= -ln(rho_infty),
0 < roh_infty <= 1.

I´ve tried it with with the Nelder Mead Solver from the Microsoft Solver Foundation, but I don´t know how to add the nonlinear conditions a + d > 0 and 0 <= gamma <= -ln(rho_infty).

My Code so far:

open Microsoft.SolverFoundation.Common
open Microsoft.SolverFoundation.Solvers

let funcFindParameters (startValues:float list) minimizationFunc =

let xInitial = startValues |> List.toArray
let lowerBound = [|-infinity; -infinity; 0.0; 0.0; 0.0; 0.0|]
let upperBound = [|infinity; infinity; infinity; infinity; infinity; 1.0|]

let solution = NelderMeadSolver.Solve(Func<float [], _>(fun parameters -> (minimizationFunc   
parameters.[0] parameters.[1] parameters.[2] parameters.[3] parameters.[4] parameters.[5])), 
xInitial, lowerBound, upperBound)

where parameters.[0] = a, and so one...

Is there perhaps some possibility to solve it with the Nelder Mead Solver or some other solver?

josliber
  • 43,891
  • 12
  • 98
  • 133
  • It's been on my wishlist for some time... writing a CSP solver library for F#. One day... – Mau Apr 02 '14 at 13:46
  • 1
    maybe worth having a look at the [R type provider](http://bluemountaincapital.github.io/FSharpRProvider/)? R comes with a broad ecosystem for optimization problems – NoIdeaHowToFixThis Apr 07 '14 at 18:51

1 Answers1

3

One comment, is that I would stay away from the Microsoft.SolverFoundation, I have wasted hours of my life on bad algorithms coded there. The R type provider is much better.

With that said, a common hack is simply to simply reparameterize the model to handle the constraints. For example, set:

e=a+d

as the parameter, and inside the optimzation calculate d as:

d=e-a

And now you just have to satisfy the constraint e>0, which is fixed. You can do something similar for the gamma parameter.

evolvedmicrobe
  • 2,672
  • 2
  • 22
  • 30