-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIP1.m
30 lines (25 loc) · 1 KB
/
IP1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function [x, minpower, status] = IP1(CC, A_L_eq, B_L_eq, A_eq, B_eq, lb, ub, M, e)
% IP1: Solves the mixed integer linear programming problem.
% Inputs:
% - CC: Cost coefficients for the objective function.
% - A_L_eq, B_L_eq: Matrices defining the less than or equal constraints.
% - A_eq, B_eq: Matrices defining the equality constraints.
% - lb, ub: Lower and upper bounds for decision variables.
% - M: Set of indices for binary variables.
% - e: Small value to avoid numerical issues.
% Outputs:
% - x: Solution vector.
% - minpower: Minimum power achieved.
% - status: Status of the optimization (1 if successful, 0 otherwise).
% Define objective function
f = CC';
% Set optimization options
opts = optimoptions('intlinprog', 'Display', 'off');
% Solve the mixed integer linear programming problem
[x, minpower, status] = intlinprog(f, M, A_L_eq, B_L_eq, A_eq, B_eq, lb, ub, opts);
% Check if the solution is valid
if status ~= 1
x = [];
minpower = NaN;
end
end