Skip to content

Commit

Permalink
Move cost table definition from mp.dmce_gen_mpc2 to mp.dme_gen_opf.
Browse files Browse the repository at this point in the history
Add mp.dme_gen_opf methods:
- cost_table_var_names()
- create_cost_table()
  • Loading branch information
rdzman committed Dec 7, 2023
1 parent b1ff824 commit f6060d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/+mp/dmce_gen_mpc2.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;

sci_fcn = @(ob, mpc, spec, vn)start_cost_import(ob, mpc, spec, vn);
gcip_fcn = @(ob, mpc, spec, vn)gen_cost_import(ob, mpc, spec, vn, 'P');
gciq_fcn = @(ob, mpc, spec, vn)gen_cost_import(ob, mpc, spec, vn, 'Q');
gcip_fcn = @(ob, mpc, spec, vn)gen_cost_import(ob, dme, mpc, spec, vn, 'P');
gciq_fcn = @(ob, mpc, spec, vn)gen_cost_import(ob, dme, mpc, spec, vn, 'Q');
sce_fcn = @(ob, dme, mpc, spec, vn, ridx)start_cost_export(ob, dme, mpc, spec, vn, ridx);
gcep_fcn = @(ob, dme, mpc, spec, vn, ridx)gen_cost_export(ob, dme, mpc, spec, vn, 'P', ridx);
gceq_fcn = @(ob, dme, mpc, spec, vn, ridx)gen_cost_export(ob, dme, mpc, spec, vn, 'Q', ridx);
Expand Down Expand Up @@ -111,7 +111,7 @@
end
end

function val = gen_cost_import(obj, mpc, spec, vn, p_or_q)
function val = gen_cost_import(obj, dme, mpc, spec, vn, p_or_q)
%
if isfield(mpc, 'gencost') && spec.nr
%% define named indices into data matrices
Expand Down Expand Up @@ -157,7 +157,7 @@
gc(pwl1, COST:COST+1) = [m b];
end

val = obj.gencost2cost_table(gc);
val = obj.gencost2cost_table(gc, dme);
else
val = [];
end
Expand All @@ -184,7 +184,7 @@
end
end

function tab = gencost2cost_table(obj, gencost)
function tab = gencost2cost_table(obj, gencost, dme)
%

%% define named indices into data matrices
Expand Down Expand Up @@ -236,9 +236,7 @@
cst(ipwl, :) = gencost(ipwl, COST+1:2:m);
end
end
var_names = {'poly_n', 'poly_coef', 'pwl_n', 'pwl_qty', 'pwl_cost'};
table_class = mp_table_class();
tab = table_class(npoly, p, npwl, qty, cst, 'VariableNames', var_names);
tab = dme.create_cost_table(npoly, p, npwl, qty, cst);
end

function gencost = cost_table2gencost(obj, dme, gencost0, cost, ridx)
Expand Down
12 changes: 12 additions & 0 deletions lib/+mp/dme_gen_opf.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
{'vm_setpoint', 'mu_pg_lb', 'mu_pg_ub', 'mu_qg_lb', 'mu_qg_ub'} );
end

function names = cost_table_var_names(obj)
%
names = {'poly_n', 'poly_coef', 'pwl_n', 'pwl_qty', 'pwl_cost'};
end

function tab = create_cost_table(obj, poly_n, poly_coef, pwl_n, pwl_qty, pwl_cost)
%
table_class = mp_table_class();
tab = table_class(poly_n, poly_coef, pwl_n, pwl_qty, pwl_cost, ...
'VariableNames', obj.cost_table_var_names());
end

function TorF = have_cost(obj)
%
TorF = 1;
Expand Down

0 comments on commit f6060d2

Please sign in to comment.