X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 Apr 2010 10:38 AM by  anon
Help on problems when calling two or more optimization functions
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
16 Apr 2010 10:38 AM
    It seems that we would have trouble when using two or more optimization functions at the same time. Suppose we call IMSL_CONSTRAINED_NLP with an objective function func_obj and a gradient function func_grad. In the function func_grad, we call IMSL_FMINV with an objective function func_obj2 and a gradient function func_grad2 to evulate the gradient. We would have the following error information: Attempt to call undefined procedure/function: 'func_grad2'. If we remove func_grad2 from IMSL_FMINV, the information would be: Attempt to call undefined procedure/function: 'func_obj2'. So I guess that we could not call a IDL optimization function inside another IDL optimization function. Is it true? If so, it would be a limitation of IDL optimization functions. Is there any work around to fix this problem? Thanks!      

    Deleted User



    New Member


    Posts:
    New Member


    --
    26 Apr 2010 04:53 PM
    Hi, please look at the following sample code. ================================================================= PRO Nlp_fcn2, x, iact, result, ierr    CASE iact OF       0 : result = (x[0] - 0.5)^2 + (x[1] - 0.5)^2    ENDCASE    ierr = 0    END PRO Nlp_grad, x, iact, result       ans = IMSL_CONSTRAINED_NLP('Nlp_fcn2', 0, 2, MEQ = 0)       CASE iact OF       0:result = [ 2 * (x(0) - 2.), 2 * (x(1)-1.)]       1:result = [1., -2. ]       2:result = [-0.5*x(0), -2.0*x(1)]    ENDCASE    RETURN END   PRO Nlp_fcn, x, iact, result, ierr    tmp1 = x(0)-2.    tmp2 = x(1) - 1.    CASE iact OF       0:result = tmp1^2 + tmp2^2       1:result = x(0) -2.*x(1) + 1.       2:result = -(x(0)^2)/4. - x(1)^2 + 1.    ENDCASE    ierr = 0 END pro Test          ans2 = IMSL_CONSTRAINED_NLP('nlp_fcn', 2, 2, MEQ = 1, GRAD = 'nlp_grad')     PM, ans2, title='X with Analytic gradient'      end =================================================================   If we remove "ans = IMSL_CONSTRAINED_NLP('Nlp_fcn2', 0, 2, MEQ = 0)" in the function Nlp_grad, Test would work; otherwise, it would fail, though the statement "ans = IMSL_CONSTRAINED_NLP('Nlp_fcn2', 0, 2, MEQ = 0)" is correct itself. Any suggestion about how to fix this problem? Thanks!  
    You are not authorized to post a reply.