forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:44 pm

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  [ 2 posts ] 
Author Message
 Post subject: How to constrain parameters in a nonlinear equation?
PostPosted: Fri Jul 19, 2013 5:10 pm 
Offline

Joined: Fri Jul 19, 2013 4:03 pm
Posts: 2
I am trying to solve the equation: a * ( x ^ c / b ^ c + 1 ) ^ (1/c) where a/b = constant

I can solve the equation but I don't know how to introduce the constraint a/b = constant (or alternatively ABS(constant - a/b) is minimized)

Would anyone be kind enough to set me on the right track here?

So far I have :

Code:
Public Sub function_ShrinkageFit_func(c As Double(), x As Double(), ByRef func As Double, obj As Object)
     func = c(0) * ((((x(0) ^ c(2)) / (c(1) ^ c(2))) + 1) ^ (1 / c(2)))
End Sub

Public Function ShrinkageFit()
    Dim x(,) As Double
    Dim y() As Double
    Dim c() As Double = New Double() {1, 1, 10}
    Dim bndl() As Double = New Double() {0.0, 0.0, 0.0}
    Dim bndu() As Double = New Double() {Double.PositiveInfinity, Double.PositiveInfinity, 50.0}
    Dim epsf As Double = 0
    Dim epsx As Double = 0.000001
    Dim maxits As Integer = 0
    Dim info As Integer
    Dim state As alglib.lsfitstate = New alglib.lsfitstate()
    Dim rep As alglib.lsfitreport = New alglib.lsfitreport()
    Dim diffstep As Double = 0.0001

    ... fill x and y

    alglib.lsfitcreatef(x, y, c, diffstep, state)
    alglib.lsfitsetbc(state, bndl, bndu)
    alglib.lsfitsetcond(state, epsf, epsx, maxits)
    alglib.lsfitfit(state, AddressOf function_ShrinkageFit_func, Nothing, Nothing)
    alglib.lsfitresults(state, info, c, rep)


Thanks,
Michael


Top
 Profile  
 
 Post subject: Re: How to constrain parameters in a nonlinear equation?
PostPosted: Mon Jul 22, 2013 8:44 pm 
Offline

Joined: Fri Jul 19, 2013 4:03 pm
Posts: 2
Kindly ignore this. I was missing the obvious. Simply replace 'b' with 'a/constant' and get on with life.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 43 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