Each element of INTCON must be an integer in the range [1 numVars], ([1 1]). What is the meaning??

15 Ansichten (letzte 30 Tage)
This is the code
% Load case30 data from MATPOWER
mpc = loadcase('case30.m');
% Extract data for easier manipulation
gen_data = mpc.gen;
baseMVA = mpc.baseMVA;
ng = size(gen_data, 1);
% Define variables and parameters
P_min = gen_data(:, 10) / baseMVA; % minimum generator output
P_max = gen_data(:, 9) / baseMVA; % maximum generator output
c = gen_data(:, 7); % cost of generation
c0 = sum(c); % fixed cost
demand = sum(mpc.bus(:, 3)) / baseMVA; % total demand
% Formulate the MILP problem
f = c' * P_max + c0; % objective function
Aeq = ones(1, ng); % equality constraint matrix
Aeq = Aeq';
beq = demand; % total demand
lb = P_min; % lower bounds for P XXXXXXXXXXXX
ub = P_max; % upper bounds for P
intcon = 1:ng; % integer variables
intcon = intcon'; %XXXXXXXXXXXXXXXXXXXXXXXXX
% Solve the MILP problem
options = optimoptions('intlinprog','Display','off');
[P_opt, fval, exitflag] = intlinprog(f, intcon, [], [], Aeq, beq, lb, ub, options);
% Display the results
disp('Optimal power generation:');
disp(P_opt);
% Calculate total cost
total_cost = fval / baseMVA;
disp(['Total cost: $' num2str(total_cost)]);
In section "[P_opt, fval, exitflag] = intlinprog(f, intcon, [], [], Aeq, beq, lb, ub, options);", the command window said :Each element of INTCON must be an integer in the range [1 numVars], ([1 1])

Antworten (1)

Torsten
Torsten am 26 Mär. 2023
f = c' * P_max + c0; % objective function
is a scalar value. Thus intlinprog assumes you want to solve a problem with only one unknown.
But you define "intcon" as 1:ng which would mean you have at least ng unknowns.
These two settings contradict each other.

Kategorien

Mehr zu Linear Programming and Mixed-Integer Linear Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by