Problem with fmincon solver results

Home Forums Matlab Problem with fmincon solver results

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

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #618

    Greatness
    Participant

    Hello,

    I used the optimization solver “fmincon” to solve an optimization problem. The code is given below:

    x0 = 0.05; %initial value
    lb = 0.05; %lower bound
    ub = 0.2; %upper bound
    options = optimoptions(‘fmincon’,'Algorithm’,'interior-point’,'Display’,'iter’);
    [xkOptm,fvalOptm,exitflagOptm,outputOptm,lambdaOptm] = fmincon(‘SSE_4_traditional_CFD_straight’,x0,[],[],[],[],lb,ub,[],options);

    The function ‘SSE_4_traditional_CFD_straight’ gives the objective function:

    function SSE=SSE_4_traditional_CFD_straight(Cu,exp_a1b1,Yb)
    load(‘traditional_CFD_straight_data.mat’) %load data
    CFD_prediction_straight; % to give us the model prediction, Yb
    SSE=(sum((Yb-exp_a1b1).^2)); %calculate sum of squared errors – compares model %prediction with experimental data

    where Yb, the predicted model is obtained from (CFD_prediction_straight):

    theta = [0.4 0.4 0.4]; %assume an intial value for theta
    lob = [1e-4 1e-4 1e-4]; upb = [10 10 10]; %lob-lower & upb-upper limit for theta

    [dmodel, perf] = dacefit(S, Y, @regpoly0, @corrgauss, theta, lob, upb); %calculates model parameters

    %Fit the meta-model parameters to the kriging model form
    [Yb, var] = predictor(a1, dmodel); %predicts model

    The code is to give an optimum value for Cu at minimum SSE (sum of squared errors) and likewise obtain the number of function evaluations. Each time we provide new values for for a1 and exp_a1b1, say a2 and exp_a2b2, the optimum value for Cu and number of function evaluations should change, but these are not changing.

    Where could there be a mistake in the code? Please kindly help. Thank you.

    #619

    cK
    Keymaster

    Can you attach the script files?

    #620

    cK
    Keymaster

    Probably the mat file being loaded is overwriting the input arguments being passed into the function.

    #621

    Greatness
    Participant

    Thank you for the reply. I’m not sure about this but the Cu seems to come from the optimum value provided from fmincon solver. There is no ‘Cu’ in the uploaded data. The ‘exp_a1b1′ came from the uploaded data, while ‘Yb’ came from the code ‘CFD_prediction_straight’.

    The same values for optimum ‘Cu’ and number of function evaluations are obtained each time the input into the function changes.

    I’ve attached the data file and part of the script files (not complete due to the maximum file size allowed)

    Attachments:
    You must be logged in to view attached files.
    #627

    cK
    Keymaster

    If Cu is the only parameter you want to subject to minimisation, then your function definition should have only that input argument.
    function SSE=SSE_4_traditional_CFD_straight(Cu)
    exp_a1b1 and Yb are anyways being generated inside the function.

    #630

    Greatness
    Participant

    I’ve done this, but the problem is it keeps giving the same optimum Cu value irrespective of the change in input i.e. for instance if exp_a1b1 changes to exp_a2b2. It seems it keeps getting the Cu value based on the supplied initial value, x0, lower bound & upper bound.

    Also the number of function evaluations remains the same when the input changes.

    #631

    cK
    Keymaster

    What is the exitFlag value you see? It might mean that the optimum is independent of exp_a1b1 or it’s getting caught in local minimum. Try changing the intial guess to various points on a grid.

    #632

    Greatness
    Participant

    The exitFlag is always 1. The optimum is actually independent of exp_a1b1 because exp_a1b1 is an experimental data which does not depend on the adjusted Cu value. I tried changing the initial guess to various points. Using 0.05 and 0.2 (the lower and upper respectively) gave different optimum values but on using values between 0.05 and 0.2, it gave the same values e.g. using 0.07 will give optimum value of 0.07.

    #666

    cK
    Keymaster

    Irrespective of the result, the function definition should be the way I mentioned earlier (with only Cu as input if that is the only one being minimised w.r.t).

    D you suspect that the end value isn’t really optimal for any reasons other than parameter independence?

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

You must be logged in to reply to this topic.