Forum Replies Created
-
AuthorPosts
-
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.
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.
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.11 May, 2015 at 2:16 pm in reply to: Using an Objective function in fmincon Optimization solver #580Many Thanks for your suggestion. It was very helpful.
Hello,
I eventually wrote this code which seems to have worked but stopped the data generation at the 3rd loop. The error message is:Subscripted assignment dimension mismatch.
Error in data_generation (line 28)
XD(1:7,i)=eval(sprintf(‘XD%d’,i));The function and script required to run “data_generation.m” are found attached.
Kindly help to have a look. Thank you.clear all
clcN =500; k = 1;
Xk = hss(N,k);
r = Xk;
x_hss=r;
X=x_hss;FR=[0.01;0.11;0.19;0.34];
XD=[0;1;2;3;4;5;7];
for i=1:500,
eval(sprintf(‘XD%d=repmat(XD,[1 1])’, i)); %generates 1st columneval(sprintf(‘FR%d=repmat(FR(i,:),[7 1]),’,i)); %generates 2nd column
eval(sprintf(‘Cu%d = repmat(X(i,:),[7 1])’, i)); %generates 3rd column
XD(1:7,i)=eval(sprintf(‘XD%d’,i));
FR(1:7,i)=eval(sprintf(‘FR%d’,i));
Cu(1:7,i)=eval(sprintf(‘Cu%d’,i));
S(1:7,i)=eval(sprintf(‘XD(1:7,i)’,'FR(1:7,i)’,'Cu(1:7,i)’,i)); %generates %500matrices for 1st,2nd &3rd col
endAttachments:
You must be logged in to view attached files.Thank you for your reply. The data is structured as seen below:
S =
0 0.0100 0.0900
1.0000 0.0100 0.0900
2.0000 0.0100 0.0900
3.0000 0.0100 0.0900
4.0000 0.0100 0.0900
5.0000 0.0100 0.0900
7.0000 0.0100 0.0900
0 0.1100 0.0900
1.0000 0.1100 0.0900
2.0000 0.1100 0.0900
3.0000 0.1100 0.0900
4.0000 0.1100 0.0900
5.0000 0.1100 0.0900
7.0000 0.1100 0.0900
0 0.1900 0.0900
1.0000 0.1900 0.0900
2.0000 0.1900 0.0900
3.0000 0.1900 0.0900
4.0000 0.1900 0.0900
5.0000 0.1900 0.0900
7.0000 0.1900 0.0900
0 0.3400 0.0900
1.0000 0.3400 0.0900
2.0000 0.3400 0.0900
3.0000 0.3400 0.0900
4.0000 0.3400 0.0900
5.0000 0.3400 0.0900
7.0000 0.3400 0.0900This is matrix S for 3rd column being 0.09. The 1st and 2nd column remains the same while 3rd column changes in value within the range of 0.005 to 0.35. So, I need to create matrix for each of these values of the 3rd column (between 0.005 & 0.35), about 127 data. It’ll be cumbersome to load the data one after another. This is the challenge.
You can just give a code which gives a clue on how this can work. Thanks.
Thanks cK. I eventually used:
expr = sprintf(‘[Yb_%s, var_%s] = predictor(%s,dmodel);’,cell_data{i}, cell_data{i}, cell_data{i});
and it worked. Thank you.
Now please permit me to ask an additional question. This code above was just for few values of input S e.g. S_0_07, S_0_085 etc. Now, if I need to use more than 200values of inputs, I think it’s better to write a code which generates the input values rather than loading them.
The input values are each 28 by 3, where the 1st & 2nd columns are always the same while the 3rd column changes. for instance, S=[0,0.01,0.09;1,0.01,0.09;2,0.01,0.09;3,0.01,0.09;4,0.01,0.09;5,0.01,0.09;7,0.01,0.09;0,0.11,0.09;1,0.11,0.09;2,0.11,0.09;3,0.11,0.09;4,0.11,0.09;5,0.11,0.09;7,0.11,0.09;0,0.19,0.09;1,0.19,0.09;2,0.19,0.09;3,0.19,0.09;4,0.19,0.09;5,0.19,0.09;7,0.19,0.09;0,0.34,0.09;1,0.34,0.09;2,0.34,0.09;3,0.34,0.09;4,0.34,0.09;5,0.34,0.09;7,0.34,0.09]; % These are for 3rd column being 0.09.
But I need the same 1st & 2nd columns with different values of the 3rd column which can start from 0.01 to 0.40. So, I’m thinking of having a code which can generate this data for me each time the calculation: [Yb] = predictor(S, dmodel); is required.
Please, how do you think I can achieve this? Thank you.
I’m not sure about this, but I used the code below and got this error message: “Undefined variable “cell_dataS_0_07″ or class “cell_dataS_0_07.mat”. It seems not to be working.
The code is given below:
cell_data={‘S_0_07.mat’,'S_0_085.mat’,'S_0_088.mat’,'S_0_089.mat’,'S_0_0895.mat’,'S_0_091.mat’,'S_0_092.mat’,'S_0_093.mat’,… ‘S_0_094.mat’,'S_0_0945.mat’,'S_0_10.mat’,'S_0_105.mat’,'S_0_11.mat’,'S_0_115.mat’,'S_0_12.mat’,'S_0_125.mat’,…
‘S_0_13.mat’,'S_0_135.mat’,'S_0_15.mat’};
for i = 1:20
expr = sprintf(‘[Yb%s, var%s] = predictor(cell_data%s,dmodel);’,cell_data{i}(2:end), cell_data{i}(2:end), cell_data{i});eval(expr);
endYou can please help to have a look. Thanks.
Attachments:
You must be logged in to view attached files.Sorry, I don’t seem to understand the code. ‘[Yb%s, var%s] = predictor(%s,dmodel);’ seems to be a statement. The “%s” does it imply each input data and corresponding output data? If this is so, How does it recognise each of the S…. input data values in a loop? The “matfiles{i}” are they the S… input data? If they are, how are the S…input data recognized?
The problem is how can I pick each of the S… input data values in a loop to do calculation i.e. S_0_07.mat, S_0_085.mat,……etc ?
I don’t really know how to implement the code you gave. Maybe you can help to explain briefly and give examples.
Thanks. -
AuthorPosts