Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I arrange the optimization problem in the correct manner to solve using Intlinprog ?

조회 수: 1(최근 30일)
Gayan Lankeshwara
Gayan Lankeshwara 2019년 11월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
This is the code I have written for a Integer Linear Programming problem.
There is an error at the section where CI is defined inside the optimisation problem.
When I run this, I get "Undefined function or variable 'CI'."
I know that its wrong, but I am kind of struggling to transform the relationship into an optimisation problem here.
Some of the usual equations are,
T_room in the second equation will be used to calculate the CI in equation (1).
Actually I am running the code only for a single time step.
Later I have to modify it for multiple time steps.
Please help me to arrange the optimisation problem in the right manner and to solve it.
Thanks.
clc;
clear all;
%% defining the parameters for each case
%%% Appliance power levels
Appliance_Power = [2 ; 4 ; 5]; % for [App1 ; App2 : App3]
%%% Lower level of preferred temperature for the appliances
T_lower = [22 ; 20; 21]; % for [App1 ; App2 : App3]
%%% Upper level of preferred temperature for the appliances
T_upper = [28 ; 28; 29];% for [App1 ; App2 : App3]
%% assuming the initial room temperature
T_room_initial = 33; %% assume the same for all
%% outside temperature variation
T_ambient = 30;
%% house parameters
L1 = 30; % length
L2 = 10; % width
L3 = 4 ; % breadth
beta = 40; % roof angle
deltaAir = 1.225; % mass of the air
%% calculating the volume of the house
V_house = L1* L2* L3 + tan(beta)* L1* L2 ;
%% mass of air inside the house
M_air = V_house * deltaAir ;
%% Equivalent thermal resistance
R_eq = 3.1965e-6 ; %% the value in the paper was used, did not calculate
%% thermal capacity of air
c_a = 1.01 ; %% kJ/kg deg C
%% specifications for the air conditioner
COP = 2 ; %% considering the Daikin brand air conditioner
%% for power levels of appliances
K = Appliance_Power./sum(Appliance_Power); %% cumulative power of appliances
%% now trying to develop the optimisation problem
x = optimvar('x' ,3, 'LowerBound', 0, 'UpperBound', 1); %% 3 x 1 binary variable
%% defining the parameters for alpha and beta
alpha = 0.1 ;
beta = 100 ;
%% problem formulation
prob = optimproblem('Objective', alpha*K(1)*x(1) + beta *CI(1) + alpha*K(2)*x(2) + beta * CI(2) + alpha*K(3)*x(3) + beta *CI(3));
%% CI parameter definition for each
const1 = CI(1) == (2*T_room(1) - T_lower(1) - T_upper(1))./( T_upper(1)- T_lower(1));
const2 = CI(2) == (2*T_room(2) - T_lower(2) - T_upper(2))./( T_upper(2)- T_lower(2));
const3 = CI(3) == (2*T_room(3) - T_lower(3) - T_upper(3))./( T_upper(3)- T_lower(3));
%% room temperature update constants
const4 = T_room(1) == (1- (deltaT/(1000*M_air*c_a*R_eq)))*T_room_initial + (deltaT/(1000*M_air*c_a*R_eq))* T_ambient - x(1)* (COP * Appliance_Power(1) * deltaT/(0.000277*M_air*c_a));
const5 = T_room(2) == (1- (deltaT/(1000*M_air*c_a*R_eq)))*T_room_initial + (deltaT/(1000*M_air*c_a*R_eq))* T_ambient - x(2)* (COP * Appliance_Power(2) * deltaT/(0.000277*M_air*c_a));
const6 = T_room(3) == (1- (deltaT/(1000*M_air*c_a*R_eq)))*T_room_initial + (deltaT/(1000*M_air*c_a*R_eq))* T_ambient - x(3)* (COP * Appliance_Power(3) * deltaT/(0.000277*M_air*c_a));
%% power level constraints
const7 = Appliance_Power(1)* x(1) + Appliance_Power(2)* x(2) + Appliance_Power(3)* x(3) >= 4 ;
prob.Constraints.const1 = const1 ;
prob.Constraints.const2 = const2 ;
prob.Constraints.const3 = const3 ;
prob.Constraints.const4 = const4 ;
prob.Constraints.const5 = const5 ;
prob.Constraints.const6 = const6 ;
prob.Constraints.const7 = const7 ;
problem = prob2struct(prob) ;
%% solving the problem
[sol, fval, exitflag, output] = intlinprog(problem);

답변(0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by