forum.alglib.net http://forum.alglib.net/ |
|
How to constrain parameters in a nonlinear equation? http://forum.alglib.net/viewtopic.php?f=2&t=889 |
Page 1 of 1 |
Author: | mcourtin [ Fri Jul 19, 2013 5:10 pm ] |
Post subject: | How to constrain parameters in a nonlinear equation? |
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 |
Author: | mcourtin [ Mon Jul 22, 2013 8:44 pm ] |
Post subject: | Re: How to constrain parameters in a nonlinear equation? |
Kindly ignore this. I was missing the obvious. Simply replace 'b' with 'a/constant' and get on with life. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |