Using an Objective function in fmincon Optimization solver

Home Forums Matlab Using an Objective function in fmincon Optimization solver

This topic contains 2 replies, has 2 voices, and was last updated by  Greatness 8 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #578

    Greatness
    Participant

    I’m trying to use the ‘fmincon’ optimization solver to maximize a particular objective function given below:

    function ei=Calc_EI(k1k2,dmodel,Cbin_,F_)
    .
    .
    .
    ei = EI_SSE(mu, sigma, y, sse_min);

    k1k2,dmodel,Cbin_ and F_ are variables provided into the objective function. Hence, the subsequent calculation of ei (as seen above).

    This objective function is then provided into the fmincon optimization solver:
    myEI=@(k1k2)(Calc_EI(k1k2,dmodel,Cbin_,F_));
    [xkEI,fvalEI,exitflagEI,outputEI,lambdaEI] = fmincon(myEI,x0,[],[],[],[],lb,ub,[],options);

    In the course of trying to run the solver, there was an error message:

    “Undefined function or variable ‘dmodel’.

    Error in @(k1k2)((Calc_EI(k1k2,dmodel,Cbin_,F_)))

    Error in fmincon (line 635)
    initVals.f = feval(funfcn{3},X,varargin{:});

    Error in test_calibration (line 45)
    [xkEI,fvalEI,exitflagEI,outputEI,lambdaEI] = fmincon(myEI,x0,[],[],[],[],lb,ub,[],options);

    Caused by:
    Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.”

    IT SEEMS THE fmincon solver IS NOT SEEING THE VARIABLE, ‘dmodel’ and probably the same will apply to Cbin_ and F_. PLEASE HOW CAN I MAKE THE fmincon Solver TO SEE THESE VARIABLES FOR THE CALCULATION? THESE VARIABLES HAVE ALREADY BEEN PROVIDED IN THE OBJECTIVE FUNCTION CALCULATION.

    I LOOK FORWARD TO YOUR REPLY. THANK YOU.

    #579

    cK
    Keymaster

    Why use a function handle when you have already created a separate file for the function. You might just do fmincon('Calc_El',……
    In case you need to use function handle, the pair of parentheses must define all inputs. The error is a result of missing 3 other inputs dmodel, cbin & F.
    handleFunc = @(x,y,z)(Func(x,y,z));

    #580

    Greatness
    Participant

    Many Thanks for your suggestion. It was very helpful.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.