Error msg: Undefined function or variable 'optimproblem'. Error in optimize_plant_operation (line 6) prob = optimprobl​em('Object​iveSense', 'maximize');

3 views (last 30 days)

function optimal_power = optimize_plant_operation(GT_avail, HRSG_avail)
% GT_avail: 4-element binary vector indicating GT availability
% HRSG_avail: 4-element binary vector indicating HRSG availability

% Create optimization problem
prob = optimproblem('ObjectiveSense', 'maximize');

% Decision variables
x_GT = optimvar('x_GT', 4, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
x_ST_full = optimvar('x_ST_full', 2, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1); % Full load operation
x_ST_half = optimvar('x_ST_half', 2, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1); % Half load operation
y_mode = optimvar('y_mode', 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);

% Calculate ST availability based on GT-HRSG pairs
% ST1 is available if at least one pair (GT1+HRSG1 or GT2+HRSG2) is possible
ST1_avail = (GT_avail(1) && HRSG_avail(1)) || (GT_avail(2) && HRSG_avail(2));
% ST2 is available if at least one pair (GT3+HRSG3 or GT4+HRSG4) is possible
ST2_avail = (GT_avail(3) && HRSG_avail(3)) || (GT_avail(4) && HRSG_avail(4));

% Objective: maximize total power generation
prob.Objective = 115*sum(x_GT) + 115*sum(x_ST_full) + 57.5*sum(x_ST_half);

% ST1 Operation Constraints
pair1 = x_GT(1)*HRSG_avail(1); % GT1 + HRSG1
pair2 = x_GT(2)*HRSG_avail(2); % GT2 + HRSG2

% ST1 can operate at full load if both pairs are available
prob.Constraints.ST1_full = x_ST_full(1) <= min(pair1, pair2);

% ST1 can operate at half load if exactly one pair is available
prob.Constraints.ST1_half_upper = x_ST_half(1) <= pair1 + pair2 - 2*x_ST_full(1);
prob.Constraints.ST1_half_lower = x_ST_half(1) >= max(pair1, pair2) - x_ST_full(1);

% ST1 can't operate at both full and half load
prob.Constraints.ST1_exclusive = x_ST_full(1) + x_ST_half(1) <= 1;

% ST1 availability constraint
prob.Constraints.ST1_avail = x_ST_full(1) + x_ST_half(1) <= ST1_avail;

% ST2 Operation Constraints
pair3 = x_GT(3)*HRSG_avail(3); % GT3 + HRSG3
pair4 = x_GT(4)*HRSG_avail(4); % GT4 + HRSG4

% ST2 can operate at full load if both pairs are available
prob.Constraints.ST2_full = x_ST_full(2) <= min(pair3, pair4);

% ST2 can operate at half load if exactly one pair is available
prob.Constraints.ST2_half_upper = x_ST_half(2) <= pair3 + pair4 - 2*x_ST_full(2);
prob.Constraints.ST2_half_lower = x_ST_half(2) >= max(pair3, pair4) - x_ST_full(2);

% ST2 can't operate at both full and half load
prob.Constraints.ST2_exclusive = x_ST_full(2) + x_ST_half(2) <= 1;

% ST2 availability constraint
prob.Constraints.ST2_avail = x_ST_full(2) + x_ST_half(2) <= ST2_avail;

% Mode constraints
prob.Constraints.mode_cc = y_mode <= sum(x_ST_full + x_ST_half);
prob.Constraints.mode_sc = (1 - y_mode) >= 1 - sum(x_ST_full + x_ST_half);

% STs can only operate in combined cycle mode
prob.Constraints.ST1_mode = x_ST_full(1) + x_ST_half(1) <= y_mode;
prob.Constraints.ST2_mode = x_ST_full(2) + x_ST_half(2) <= y_mode;

% GT availability constraints
for i = 1:4
prob.Constraints.(['GT_avail_' num2str(i)]) = x_GT(i) <= GT_avail(i);
end

% Solve the problem
options = optimoptions('intlinprog', 'Display', 'off');
[sol, fval, exitflag] = solve(prob, 'Options', options);

if exitflag > 0
optimal_power = fval;

% Display results
disp('Optimal Operating Configuration:');
disp(['GTs operating: ' num2str(sol.x_GT')]);

for st = 1:2
if st == 1
st_avail = ST1_avail;
else
st_avail = ST2_avail;
end

if st_avail
if sol.x_ST_full(st) > 0.9
disp(['ST' num2str(st) ' operating at full load (115 MW)']);
elseif sol.x_ST_half(st) > 0.9
disp(['ST' num2str(st) ' operating at half load (57.5 MW)']);
else
disp(['ST' num2str(st) ' available but not operating']);
end
else
disp(['ST' num2str(st) ' unavailable (no GT-HRSG pairs available)']);
end
end

if sol.y_mode > 0.9
disp('Operating mode: Combined Cycle');
else
disp('Operating mode: Simple Cycle');
end
disp(['Total power output: ' num2str(optimal_power) ' MW']);

% Display detailed pairing information
if ST1_avail
disp('ST1 possible sources:');
if GT_avail(1) && HRSG_avail(1)
disp(' GT1 + HRSG1 available');
end
if GT_avail(2) && HRSG_avail(2)
disp(' GT2 + HRSG2 available');
end
end

if ST2_avail
disp('ST2 possible sources:');
if GT_avail(3) && HRSG_avail(3)
disp(' GT3 + HRSG3 available');
end
if GT_avail(4) && HRSG_avail(4)
disp(' GT4 + HRSG4 available');
end
end
else
error('No feasible solution found');
end
end

Answers (2)

Torsten
Torsten on 4 May 2025
Edited: Torsten on 4 May 2025
"optimproblem" was introduced in R2017b:
at the bottom of the page under Version History.

TED MOSBY
TED MOSBY on 4 May 2025
Hi @Paul,
The function "optimproblem" was introduced in R2017b, hence to use this function you will have to upgrade to a higher version.
As the documentation for R2015a is no longer present online, if you still wish to refer to the version specific documentation, you can type "doc" in the MATLAB command window.
Hope it helps!

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!