forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 1:49 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Boundary conditions in minlm
PostPosted: Thu Oct 11, 2012 5:52 pm 
Offline

Joined: Thu Oct 11, 2012 5:41 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Boundary conditions in minlm
PostPosted: Thu Oct 11, 2012 6:18 pm 
Offline

Joined: Thu Oct 11, 2012 5:41 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Boundary conditions in minlm
PostPosted: Fri Oct 12, 2012 5:32 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Yes, minlmcreatev() re-initializes structure and erases all previous settings.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group