Assigning different upper and lower bounds to function input variables when calling the function during optimization
조회 수: 14 (최근 30일)
이전 댓글 표시
I am using the PSO to optimize the RMSE of the computed and real energy consumption.
I called the objective function inside the PSO code
CostFunction = @ energy_demand; % Objective Function/Fitness function
and defined the lower and upper bounds for x1,x2,x3,x4,x5,x6 as:
VarMin = [0.8,0.8,1,0.3,0.1,0.1]; % Lower Bound of Decision Variables
VarMax = [1,1,10,0.7,0.5,0.5]; % Upper Bound of Decision Variables
I assumed MATLAB would pick the upper and lower bounds sequentially, but I keep getting the error:
Not enough input arguments.
Error in energy_demand (line 114)
Qlong =((Ta + 273.15).^4 - (To + 273.15).^4) * x1 * x2 * As * sigma;
Error in PSO (line 58)
particle(i).Cost = CostFunction(particle(i).Position);
Error in pso1 (line 25)
out = PSO(problem, params);
The function am trying to minimize as shown below:
function RMSE = energy_demand(x1,x2,x3,x4,x5,x6)
%% greenhouse environmental parameters
environmental_input_parameters = xlsread('day and night-time environmental inputs.xlsx','T2:Z10141');
Qmeasured = xlsread('Qmeasured.xlsx');
Qreal = Qmeasured(:,2);
Ta = environmental_input_parameters(:,1); % interior temperature
slope = environmental_input_parameters(:,2); % dTa/dt
To = environmental_input_parameters(:,3); % exterior temperature
Rgo = environmental_input_parameters(:,4); % global radiation
t = environmental_input_parameters(:,5); % time series
%% Physical Constants
rho = 1.225; %Air Density in kg.m^-3
Cp = 1006.43; %specific heat capacity of air in J·kg^-1·K^-1
%% Greenhouse Physical Dimensions
Vol = 16315.517 ; % Greenhouse Volume in V/m^-3
As = 5079.9263; % surface area of the greenhouse in m^2
Ag = 3393.324; % greenhouse ground surface area in m^2
%% Thermal Model
%Longwave Radiation
Qlong =((Ta + 273.15).^4 - (To + 273.15).^4) * x1 * x2 * As * sigma;
%% Heat exchanged between cover and the exterior of the greenhouse
Qcover = (Ta - To) * As * x3 * x4;
%% Heat Flux of Air
Qair = slope * Vol * rho * Cp;
%% Net Solar Radiation
Qsolar = Rgo * As * x5 * x6;
%% Computed greenhouse energy consumption
Qcomputed = Qair + Qlong + Qcover - Qsolar;
alpha = sum((Qcomputed(:) - Qreal(:)).^2);
N = size((Qcomputed(:)),1);
RMSE = sqrt(alpha./N);
end
댓글 수: 1
muhammad hamza
2021년 6월 11일
Same Issue im trying to minimize my objective function for boost converter which im contolling with FOPID.I need to set limits for each of 5 parameters of FOPID i need to find.
답변 (1개)
Alan Weiss
2021년 6월 11일
You need to write your function of one variable, say x = [x1,x2,x3,x4,x5]. For example,
function RMSE = energy_demand(x) % Here x has 5 components
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!