Constrained Nonlinear Optimization

Hello,
I have some trouble using the  "Constrained Nonlinear Optimization.vi"
Apart from the manual I could not find much information on the algorithm on the internet... It look like often my program gets stuck in a loop inside the subvi "isisubopt.vi" (L-->inf , matrix inversion results in a matrix of zeros). This happens with some datasets, not with others, but when it gets stuck, there is no possibility to leave the loop and thus I have to quit the vi.
Is there reason for this eternal loop, and it there any way to avoid this situation?
Thanks, Dirk 

Hi Dirk,
I'm not familiar with the algorithm, but the Wikipedia page is likely a good start point. There's a PDF at the bottom called "Introduction to Sequential Programming".
What is the difference in your data sets? Same size?
Jeff | LabVIEW Software Engineer

Similar Messages

  • Curve Fit of ODE, should I use Lev-Mar or Constrained Nonlinear Optimization?

    I wanna do a curve fitting of differential equations, following is the equations:
    dx/dt = u*x-a*x
    ds/dt = b*u*x+c*x
    dp/dt = d*u*x+e*x+f*p
    and u = um*s/(km+s+s^2/ki)
    I've tried "nonlinear curve fit( Lev-Mar)", but I met difficulties when writing the f(x,a) of Lev-Mar.
    Then I tried "Constrained Nonlinear Optimization", I found that the example "Estimate Nonlinear Spring Constant.vi"
    in the "labview\examples\math\curvefit.llb" was similar to the fitting I tried to do, but there was only one parameter
    need to estimate in this example,but what I need is to estimate 3 parameters.
    However,I modified the example to my equations, it failed again.
    How can I achieve this? is it possible to do this fit only using Labview VIs or need Matlab Script Node?
    Any help will be appreciated.

    I forgot to mention that in the equations above,  a,b,c,d,e,f is constant,
    and the data of x,s,p corresponding with the data of time is already known,
    and which parameters I wanna identify is um,km,and ki
    帖子被myafu在12-22-2006 01:33 AM时编辑过了

  • Preconditioner or preconditioning for Constrained Nonlinear Optimization VI and Downhill Simplex nD VI

    Dear users,
    do optimisation algorithms, such as the Constrained Nonlinear Optimization VI and the Downhill Simplex nD VI, use internal preconditioning or does the user have to do it on their own? There is no note or word in the help about (pre)scaling the functions or the variables. On the other hand, there is no word about any nonnecessity to do so.
    Cheers,

    Hello ghighuphu,
    the VI's "just" do their algorithm, so they aren't using internal preconditioning. The user have to do this by himself.
    Best regards

  • Non-varying variable in Constrained Nonlinear Optimization

    I have built a labview VI so as to execute an optimization problem that I had previously solved using Matlab's fmincon. The transition wasn't difficult and the VI mostly works except for one variable.
    The VI is expected to optimize an array of four variables: the first three will be input to a control systems function, and the last is converted to int to be used for array allocation (think of it as a time switch for the second and the third variable). When I run the code, that last variable doesn't change, not by one iota. To confirm this, I set a breakpoint with a probe and watch as Labview would modify the three other variable but still has the fourth variable at 140.00000 . I've tried varying the criteria and settings, but to no avail.
    What am I missing, or is this somehow normal?
    Solved!
    Go to Solution.

    not all optimization routines use partial derivatives (hence "non-linear")
    I've attached the main file that decouples the variables. The resulting output will be the input to a control system whose output will be compared to a specific predetermined plot.
    Attachments:
    sequenceToRateError.vi ‏18 KB
    Times.ctl ‏5 KB

  • Constrained nonlinear curve fit can properly handle the function like ln(1+b(x-xc)/a) ?

    Hi all,
    I met some problems about using constrained nonlinear curve fitting vi. It seems to me that this vi can't properly deal with the function like ln(1+b(x-xc)/a), a,b, and xc are the parameters, and b is in the range of 0 and -1. The reason I said that is as I used the other nonlinear fitting function in the other software, like Originlab, the fitting function can work properly.
    The error message from LV occurs as 1+b(x-xc)/a is less than zero. 
    However, due to a,b are both adjustable parameters, how could this situation happen ?
    Now I attach the vi files. The attachment includes main vi, mathmatical formula, and an input XY txt file.
    I appreciate any help or suggestion from you!!
    Here is the error message
    Joy
    Solved!
    Go to Solution.
    Attachments:
    LN-fitting.vi ‏21 KB
    LN-fittingmodel.vi ‏18 KB
    Book2.txt ‏1 KB

    Thanks for reply. whitenoiz 
    Actually I have more than 100 XY data set to test my vi. Some of the data set can be fit flawlessly. And the best fit parameters obtained from my vi are exactly the same as those from other analytical software, like OriginLab. In this case, I know my vi is valid. And in this scenario, I also found 1+b(x-xc)/a is always larger than zero with the best fit parameters (a and b). However, for certain XY data set, the error message will pop up if I use LV built-in vi, but I still can obtain the best fit parameters with OriginLab. And then I realized that error message always pops up as 1+b(x-xc)/a is less than zero, which it means to me that as LV built-in vi handles this type mathematical function, this built-in vi will encounter some difficulties. 
    I will step through my code, and also focus on the Matrix Left DivisionMV.vi, try yo find where the problem is.
    Best regards,
    Joy

  • Constrained Nonlinear Curve Fit VI: Termination Revisited (LabVIEW 8.5)

    Hello:
    In the Constrained Nonlinear Curve Fit VI, the Help for the VI states that if the number of iterations exceeds max iterations specified in the termination control, the fitting
    process terminates. Would this not indicate that if the above condition is met, the number of iterations recorded (an output of this VI) should be equal to the max iterations specified (since the VI is exits at this point).  I believe I have seen situations where this condition is met, yet the number of iterations recorded is greater than the max iterations I have specified in the termination control.  Has anyone else seen this?
    Thanks,
    Don

    Don,
    Just wanted to clarify the termination criteria for the nonlinear curve fitting routines.  There are two criteria used to terminate the fitting process:
    "max iteration" and "tolerance".  The main while loop terminates when either of these conditions is met, so:
    IF( (current_iteration > max_iteration) OR (current_tolerance <= tolerance) ) THEN (terminate loop)
    "current iteration" is just the current loop counter(starts at 1 for the first iteration).  This term is mainly a guard against having the fitting process run too long.
    tolerance is computed as the relative change between the current and previous weighted least squares values.
    Let wls = SUM_OVER_ALL_X( weight(x)*(f(x,a)-data(x))^2 )
    current_tolerance = ABS(current_wls - previous_wls)/(ABS(current_wls) + machine_epsilon)
    where ABS indicates absolute value.  Adding machine_epsilon to the denominator is just a guard against division by zero.
    For the bound nonlinear curve fit VIs, if the "method" input is chosen to be LAR or bi-square, then wls is defined as:
    wls = SUM_OVER_ALL_X( weight(x)*reweight(x)*(f(x,a)-data(x))^2 )
    where reweight(x) is a term reducing the weight of high-leverage data points.
    For both the constrained and unconstrained fitting routines, if the weight input is unwired then all points are considered to have a weight of 1.
    Christian has nicely covered the difference between the number of iterations and the number of function calls.  If your
    When the fitting process terminates the best result obtained so far is returned.  As you noted, this may be a good result, although the algorithm may not have completely converged yet.
    -Jim

  • Constrained optimization does not terminate (stopping criteria are ignored)

    Dear dev and users,
    the "constrained nonlinear optimization" in my program won't terminate. Limiting the calculation time (<1s) or the number of iterations (<300) or other "stopping criteria" does not help. The process hangs on for tens minutes (I kill it finally). The input data are nothing special compared to the other hundreds previously processed successfully. I processed my data set (600 data) and it hanged twice at different data. What other information shall I supply, so I could get some help from you, please?
    Thank you for listening.
    Cheers,
    M

    The code might be hanging inside the model or in some other subVI.
    Can you provide a bit more detail on the type of the polymorphic instance and model type you are using?
    Would it be possible for you to attach a small sample VI containing data that shows the problem?
    LabVIEW Champion . Do more with less code and in less time .

  • Using Constraints on my optimization problem (currently implemented in Unconstrained Nonlinear Opt.VI)

    I have an function f(x) that I minimize to find parameters for an algorithm. The algorithm consists of a coordinate transformation matrix. The transformation matrix parameters are currently found using the Unconstrained Optimization VI (simplex). I have had quite a bit of success using this VI and defining my algorithm as an objective function. I previously used Excel Solver for this application. The data set changes over time and certain parameters are tracked.
    Whenever I perform an optimization, I move the minimum parameters found to the initial guess parameters. I am finding that my initial guess parameters will remain stable for a while but at times will guess incorrectly. This can happen if I feed the algorithm bad data. It is difficult to determine that the data is bad initially, but it causes the minimization to trail off in some crazy direction that is inconsistent with the real world. This happens after repetitive minimizations and is a result of using my found results for the next iteration. However, in an ideal world, my last found results would be the best initial guess for the next optimization I perform.
    One major improvement would be to constrain my initial guess parameters. In particular, I would like to constrain the parameters I use in finding the transformation matrix (in my objective function) with lower and upper limits: 9 < R < 12, for example. Can anyone with experience using the optimization VIs, knowing the information above, help point me in the right direction? I came across the Constrained Nonlinear Optimization VI but it appears to work much different than the Simplex method; so I am not sure if this would work. I will try this next. Any thoughts?
    Chris Walker
    Certified Labview Developer

    I tried using the Constrained Nonlinear Optimization VI. I first tried it without any constraints (min or max constraints) on my parameters and it appeared to work. I could change the initial guess parameters and they would eventually end up the same minimization each time (with the same set of data). Once I add the parameter constraints, however, the VI freezes on the first iteration and I have to abort. I am not sure why and I do not get any errors.
    After some testing, it appears that the cno_isisubopt.vi subvi inside the Constrained Nonlinear Optmiziation VI is locking up. The code is attached. If I had to guess, this probably has to do with the input L advancing to Infinity and never allowing the while loop to stop. I am not sure what the internal workings of this VI are so this appears rather difficult to debug!
    This is an error that is not tracked or handled by the Constrained Nonlinear Opt Labview VI; thus freezing my program.
    Chris Walker
    Certified Labview Developer
    Attachments:
    4-4-2012 9-36-53 PM.jpg ‏158 KB

  • Constraine​d nonlinear optimizati​on, how to program equality/i​nequality constraint​s?

    Hi All,
    I need to solve following problem:
    Y1 = exp(-x1/12)*23
    Y2 = exp(-x2/5)*4 + Y1
    Constraints:
     4 <= x1 <= 9
    12 <= x2 <= 49
    Y2 = 88
    Object function (to be minimized):
    J = 1.2*x1 + 1.8*x2
    Can someone told me how I should wire equality/inequality constraints in object function VI? If I use initial values which are near constraints limits I don't achieve minimum objective function. That is the reason why I think that something is wrong in contraints programming.
    BR, Jim   

    You seem to be asking for an awful lot.  NI gives you several examples using Constrained Nonlinear Optimization and you think that showing you how to use constraints in a constrained optimization is important?  Besides that they give you a template for the objective function, didn't you find the minimally documented controls placed haphazardly on the FP and BD to be enough of a hint?  Finally, the main VI is not password protected so you can easily follow the code on the BD.  Sometimes it is tough to follow code, but increasing the size of the BD like they do here is very helpful.  Of course the hardest part for beginners in LV is to master dataflow.  Here they save you the trouble by using a stacked sequence in one of the first subVIs along with some sequence locals since left to right is so overrated.
    (As Homer Simpson once said "By the way I am being sarcastic").  What a complete mess, from the code itself to the documentation and examples.  But the icon is spiffy so at least there is some quality control.
    On to the task at hand:  Having stepped into that steaming pile of poo that is the BD, it seems that the equality and inequality constraints are simply bundled together.  You can ignore the equality constraint output of the objective function VI (I guess).  For your equality constraint Y2=88, just wire Y2 to an inequality constraint, and make the max and min value equal to 88.  Your x1 and x2 constraints are handled via the x minimum and maximum controls.  Try the following VI to see if it works and makes some sense.  I changed the range for x1 and x2 to include a region where the Y2 constraint is met, otherwise I get an error. 
    Message Edited by Darin.K on 05-26-2010 10:27 AM
    Attachments:
    cno_objective function Example.vi ‏15 KB
    CNO Example.vi ‏15 KB

  • Constrained optimization - function conflict and error 91?

    I am a fresh hand on Labview. I tried to use the constrained optimization approach for curve fitting, which unformately leads to the following errors.
    1. "error 91".
    I build the objective function (subvi1.vi) using "cno_objective function template.vit". When I tried to run it, an error message "error 91" pups up.
    2. "function conflict"
    When I tried to link the objective function (subvi1.vi) to the constrained nonlinear optimization block, the link is always broken, saying "function conflict".
    Any help and comments are appreciated. Thanks!
    Attachments:
    subvi1.vi ‏21 KB
    main1.vi ‏24 KB

    Hey guest,
    I checked your VIs and might have a few suggestions for you in using the constrained optimization.  First of all error 91 is usually a variant error.  It has the following text: "The data type of the variant is not compatible with the data type wired to the type input."  I believe you get this error since you don't have any data in the variant in the subVI, so it doesn't know how to translate that into a cluster.
    The broken wire you are seeing is due to there not being any connections made on the Connector Pane.  To link inputs and outputs of subVIs you need to first configure the Connector Pane by right-clicking on the icon and selecting Show Connector and then wiring the controls and indicators to terminals there.  I would suggest checking out the example for this VI, which you can then use for your application.  If you open the context help (Ctrl+H) and then hover over the VI you want and then click the detailed help link.  This will bring up the help file for this VI.  At the bottom there should be a button for Open Example. You could also find it in the Example Finder (Help >> Find Examples)
    You mentioned that you are fairly new at LabVIEW, so I wanted to point you toward a good tutorial for beginners called Learn LabVIEW in 6 Hours.  This should give you a good general overview of what LabVIEW can do.  Please let me know if you have any further questions!
    Thanks!
    Andy F.
    National Instruments

  • Constraine​d nonlinear optimizati​on covariance

    How do I calculate the covariance matrix for the Constrained Nonlinear Optimization vi ?  Can I use the lagrangian multipliers and/or hessian matrix ?

    Thanks for the response, but you misunderstand my question.  I don't want to input any covariance matrix, but calculate it (if possible) based on the outputs of the constrained nonlinear optimization vi.  See, for example, the "nonlinear curve fit" vi, where the documentation says:
    This VI generates the covariance, C, according to the following equation:
    C = (1/2)D^–1
    where D is the Hessian of the function with respect to its parameters.
    I can't apply this formula to the constrained nonlinear optimization vi, since the size of the hessian matrix is not m x m, where m is the size of the input parameter array.

  • How do I cancel a sub vi stuck in an infinite loop?

    Hi,
    I am attempting an implementation of the Constrained Nonlinear Optimization sub vi.  It works perfectly 99.9% of the time but gets stuck the other .1% of the time.  It is supposed to time out when it cannot find a solution, but it is failing to do so.  Consequently my VI regularly crashes.
    Apparently this is a known issue with this subvi.  The NI whitepaper mentions that this is caused by a subvi while loop that can get stuck in an infinite loop.  The work around is suggested to be to add a counter to the loop and exit it after a certain number of iterations.
    I can find the infinite loop occuring in the subvi.  But the sub vi opens as a clone and will not let me edit it.  How do I work around that?
    Failing that, is there a way from the main vi to cancel the optimization vi after a certain time so that the program can move on?
    Suggestions would be appreciated.

    Abort the program. Press ctrl+M when you have VI opened as clone. This will open it in edit mode.

  • Subvi waiting to run (objective function)

    Dear Users,
    I have an optimization process using unconstrained nonlinear optimization and an objective function. The only place I use that objective function is in a subVI (let's call it Optimise.vi), where I supply that to the optimization subVI (which is LabVIEW native). After running my whole program, the Optimise.vi stops and is in the idle state. But the objective function and all of its subVIs are in a running state, and their run-arrows display "SubVI waiting to run" or "Run" (always with an arrow inside an arrow). I could check on the state of the two VIs using a VI by Marche at http://forums.ni.com/t5/LabVIEW/SubVI-Waiting-to-Run/td-p/49432.
    The execution of the Optimise.vi and the objective function is set to "shared clone". If I set the execution of the Optimise.vi to "non-reentrant", then the objective function also ends in the idle state. But my program runs longer, and I would like to avoid that.
    Is this behavior bad? Should I care about it?
    Cheers,

    Dear ghighuphu,
    I really like to help you with your issue but some more informations are necessary.
    I assume you use this optimization function:
    Constrained Nonlinear Optimization VI
    http://zone.ni.com/reference/en-XX/help/371361H-01/gmath/constrained_nonlinear_optimization/
    Did you create the objective function from the template located here: labview\vi.lib\gmath\NumericalOptimization\cno_objective function template.vit ?
    In the template the execution settings should be right.
    For further troubleshooting a screenshot would be nice. Feel free to come back to me.
    Kind Regards,
    Vanessa
    AE Munich

  • Optimizati​on of function with discrete (integer) arguments

    Given: a matching unit (MU) with 2 motors which are controlled via RS232. Each motor can be driven to position from 0 to 1000 (integer only!).The value to be optimized is mismatch, which can take value from 0 to 100% and depends from the process (considered as external influence) and the MU motor positions (X1, X2).
    The purpose is to get the perfect match, i.e. mismatch close to zero (from the practical point of view Mismatch<1% is zero). The dependence Loss(X1, X2) is from the experience rather well-behaved, with only 1 minimum, which is close enough to zero as a rule. However there may be some process noise, sometimes up to 1-2% mismatch.
    I've tried (with a simulated process) the Constrained Nonlinear Optimization VI. It worked OK for floating X1, X2 values, but failed as I converted X1, X2 to integers. Is there any workaround with the ready-to-use LabVIEW VIs? We have LV full development system here.
    What optimization algorithm would better suit for the task? If I'm to implement it myself, then is following to consider:
    simplicity is strongly preferred
    large changes of (X1, X2) values cost time
    working with large mismatch should be avoided if possible
    after the motors reached the position, th system settles immediately
    Thanks

    I am no optimization expert, but I think I can explain why your integer mode version does not work.
    I put a functional global VI inside the nonlinear test objective function.vi to capture the values of the output.  I called the functional global in Read mode in a separate VI to display the results.
    objective output (DBL)(I32)
    19350.530000000 19350.530000000
    19350.530000000 19350.530000000
    19350.531144018 19350.530000000
    19350.529324858 19350.530000000
    18931.496465206 19350.530000000
    X[0] (DBL)(I32)
    500.00000000000 500.00000000000
    500.00000000000 500.00000000000
    500.00000477470 500.00000000000
    500.00000000000 500.00000000000
    261.70422390905 500.00000000000
    The conversion to integer rounds out the small changes in the first few iterations. This keeps the optimization VI from moving towards the optimum.
    Explaining what happens is one thing. Getting it to do what you want is another.  Can you optimize with DBL, convert to integers, and calculate the values for those integers (and possibly near neighbors)?
    Lynn

  • Minima of function with controls as coefficients

    I want to minimize a function with coeffecients that are driven by front panel controls.  Right now all the optimization VIs I can find have strings as formulas, so the coeffecients are fixed.
    My specific application is modeling a heat exchanger.  I have three simultaneous equations and three unknowns (heat, T coolant out, T process out).  I can write a single equation that when minimized will solve for these three variables.  But if I want to change coolant flow rate as part of the simulation, I have to modify the coefficients in the string formula.  I can build the formula with the proper coefficients everytime, but that seems pretty awkward.  Is there another way?
    (I did try the Find All Minima nD.  I thought if I made the coefficients variables themselves and set the start and end values to be equal, I could fix the coefficient but drive it with a control.  However, it seems that the start and end values are only initial values for the iterations.  I put in x^2+y^2, and set all the start and end values at 5, but the minimum was still 0.)
    It's really easy in Excel Solver

    Yes, that is the VI, and you can input any model function, not just quadratic forms.  Please keep in mind the usual caveats with these algorithms:  namely that they make no guarantees of finding the global optimum.  If your function is continuous and smooth then Quasi-Newton or Conjugate-Gradient is a good choice.  If these two fail then try the Downhill Simplex algorithm (aka Nelder-Mead simplex).  Also added in LabVIEW 8 is a Constrained Nonlinear Optimization.vi that implements a SQP algorithm that allows general nonlinear equality and inequality contstraints, and a much improved Levenberg-Marquardt implementation that accepts a VI reference as the model function.  ODE solvers were also upgraded to utilize the same sort of VI interface.
    Apologies for the sales pitch :-)
    -Jim

Maybe you are looking for

  • SO line Update

    Hi all, I am trying to update a line information in OE_ORDER_LINES ALL using apps adapter from SOA SUITE to EBIZ. I already used a PL/SQL API "UPDATELINE" under OE_ORDER_PUB which is not helping since the values not really matching with the fields in

  • Error message when opening a document "this document is being used by another user

    error message when opening a document "this document is being used by another user, do you want to make a copy? I select yes, then new message - word can not open this document.the document might be in use or it may not be an invalid document. Any su

  • Can't import into Vista

    Hi! I have had a problem with iTunes for three months now. Argh! I am having trouble importing cds and having them actually work in my library. When the songs are done "importing" the end time is listed as 789:00:00 or something like that. (They won'

  • Need to recover lost address book info

    I accidentally erased some of my cards in address book on my computer. They are on the .mac address book. How do I get the .mac address book to sync with my computer address fok and restore the lost material?

  • Changing account URL

    hi i set up a developer LCCS account a few months ago but never got around to using it. now i want to start using it but the account url i chose is unsuitable - can i change it to something more meaningful. is this possible?