forum.alglib.net
http://forum.alglib.net/

Boundary conditions in minlm
http://forum.alglib.net/viewtopic.php?f=2&t=625
Page 1 of 1

Author:  b1g3ar5 [ Thu Oct 11, 2012 5:52 pm ]
Post subject:  Boundary conditions in minlm

Has someone got a simple example of using minlmsetbc() in F#?

I've tried adding:

Code:
alglib.minlmsetbc(state, [|-1.;-1.|], [|5.;5.|])


to the minlm_d_v example, but it is just ignored.

Thanks.

Here's the code:

Code:
        let fi_errs (xs:double array) (fis:double array) o1 =
            fis.[0] <- 10.*(xs.[0]+3.)**2.
            fis.[1] <- (xs.[1]-3.)**2.
            ()           

        let mutable fis = [| 0.001; 0.01 |]
        let mutable init = [| 0.001; 0.02 |]
        let mins = [| -1.;-10.|]
        let maxs = [| 10.;10.|]
   
        let mutable state = new alglib.minlmstate()
        let mutable rep = new alglib.minlmreport()
        alglib.minlmsetbc(state, mins, maxs)

        let mvars = 2 // 2 variables
        let nopts = 2 // 2 functions in the sum
   
        AlgLib.alglib.minlmcreatev(mvars, nopts, init, 0.001, &state);
        let epsg = 0.0000001
        alglib.minlmsetcond(state, epsg, 0.0, 0.0, 0);//grad, func, xchange, maxiters
        alglib.minlmoptimize(state, (fun xs ->
                                                fun fis ->
                                                    fun o1 ->
                                                        fi_errs xs fis o1
                                           ), null, null)

        AlgLib.alglib.minlmresults(state, &init, &rep);
        let out = rep.terminationtype

Author:  b1g3ar5 [ Thu Oct 11, 2012 6:18 pm ]
Post subject:  Re: Boundary conditions in minlm

It's OK I've solved the problem - the setBC() call must be immediately before the optimize() with no other calls in between - the boundary conditions get overwritten otherwise.

N

Author:  Sergey.Bochkanov [ Fri Oct 12, 2012 5:32 am ]
Post subject:  Re: Boundary conditions in minlm

Yes, minlmcreatev() re-initializes structure and erases all previous settings.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/