optimization by changing input variables

9 visualizaciones (últimos 30 días)
Nivedhitha S
Nivedhitha S el 23 de Ag. de 2019
Respondida: Roshan Hingnekar el 2 de Sept. de 2021
Hello community,
I have a problem where i solve for 7 variables using an ode. The ode takes 4 input variables (changing with ime) and solves the equations. Now I am looking for develping an optimization problem where the 4 input variables has to be manipulated such that 1 varaible among this 7 has to be optimized (minima/maxima).
I have the following main function which calls other functions to solve the equations (not given completely and left few blanks). It has 4 input datasets (which i am currently acquring from the excel sheet). These 4 inputs has to be manipulated by the GA optimizer such that 1 varaiable- z (: ,3) has to be optimized (minimized/maximized).
Please give me your valuable suggestions/ ideas on how to proceed this.
function RF = gatrial (ip1,ip2,ip3,ip4)
%% Section 1: Input data:
tspan1 = (---)';
tspan2 = (---)';
tspan3 = (---)';
dataset = xlsread('---.csv'); % data acquiring from excel file
Data_1 = dataset(:,4);
Data_2 = dataset(:,2);
Data_3 = dataset(:,5);
Data_4 = dataset(:,3);
%% ip3 and ip4 used to calculate p7
%% Section 2: ode call
%initial values
------
z0=[--]
%num interval defining and num vars
----
%for substituting different values for each iteration
for j = 1 : num_interval
%%calling parameters which change each iteration and calling ode function
p7 = ---(j);
ip1 = Data_1(j);
ip2 = Data_2(j);
ip3 = Data_3(j);
[t2,z2] = ode45(@(t,z) eqns (t,z,p7,ip1,ip2,ip3),...
tspan1(j:j+1), z0);
t(j) = t2(end);
z0 = z2(end,:);
z(j,:) = z0;
end
%%final solved values
t = [tspan(1); t];
z = [z0init; z];
res1 = [z];
%% 2 more similar sections
--
---
----
%Final result compiled
Time = [tspan1; tspan2; tspan3];
Result_Final = [res1; res2 ; res3];
RF = [Time Result_Final];
end
  2 comentarios
Nivedhitha S
Nivedhitha S el 26 de Ag. de 2019
Update:
I have modified the function as follows:
function obj = gatrial (ip1,ip2,ip3,ip4)
% --------all eqns and ode call-------------
obj = Result_Final (end,2);
end
And also defined a GA optimization function as follows:
options = gaoptimset ('UseParallel', true, 'PopulationSize', 200)
lb=[- - - -];
ub=[- - - -];
[X fval] = ga(@gatrial,4,[],[],[],[], [lb],[ub],[], options);
Now how to get the optimal results for ip1- ip4 such that obj could be minimized?
Though ip1-4 are used ultimately in calculation of obj value, i can't write a simple straightforward equation like obj = ----*ip1+---*ip2... etc., as shown in most of the examples. I am kinda confused on how to solve this kind of problem through optimization. should i create a matrix with obj and also the 4 ips?
Any help will be appreciated.
Thanks.
Rachit Raj Rajput
Rachit Raj Rajput el 4 de En. de 2021
Have you found the solution yet?

Iniciar sesión para comentar.

Respuestas (1)

Roshan Hingnekar
Roshan Hingnekar el 2 de Sept. de 2021
Refer to the following link on optimisation toolbox

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by