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

AuthorPosts

10 March, 2016 at 10:53 pm #618
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’,'interiorpoint’,'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((Ybexp_a1b1).^2)); %calculate sum of squared errors – compares model %prediction with experimental datawhere Yb, the predicted model is obtained from (CFD_prediction_straight):
theta = [0.4 0.4 0.4]; %assume an intial value for theta
lob = [1e4 1e4 1e4]; upb = [10 10 10]; %loblower & upbupper limit for theta[dmodel, perf] = dacefit(S, Y, @regpoly0, @corrgauss, theta, lob, upb); %calculates model parameters
%Fit the metamodel parameters to the kriging model form
[Yb, var] = predictor(a1, dmodel); %predicts modelThe 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.
14 March, 2016 at 4:10 pm #619Can you attach the script files?
14 March, 2016 at 4:28 pm #620Probably the mat file being loaded is overwriting the input arguments being passed into the function.
14 March, 2016 at 5:01 pm #621Thank 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.14 March, 2016 at 5:10 pm #627If 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.14 March, 2016 at 5:42 pm #630I’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.
14 March, 2016 at 5:49 pm #631What 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.
14 March, 2016 at 6:26 pm #632The 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.
15 March, 2016 at 11:01 am #666Irrespective 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?

AuthorPosts
You must be logged in to reply to this topic.