# optimization by changing input variables

8 views (last 30 days)
Nivedhitha S on 23 Aug 2019
Answered: Roshan Hingnekar on 2 Sep 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 CommentsShowHide 1 older comment
Rachit Raj Rajput on 4 Jan 2021
Have you found the solution yet?

Roshan Hingnekar on 2 Sep 2021
Refer to the following link on optimisation toolbox

### Categories

Find more on Direct Search in Help Center and File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!