MATPOWER / MATPOWER/most

Feature request - User defined variables, constraints and costs

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
MATLAB
Stars
40
Forks
15
PR merge metrics
No merged PRs in 30d

Description

MOST does not support adding custom user-defined constraints, yet.
Indeed MATPOWER allows that through the "add_userfcn" function, but MOST doesn't

The work-arounds I could think of are:
add new constraints and costs manually
Building the MOST model, without solving it. that is: set the mpoptions to:
most.build_model = true; most.solve_model = false;

Use the functions:
build the A, L, U and VS variables to add a new constraint; using the functions: init_indexed_name and add_lin_constraint. To understand how they work, you need to take a deep look at the MOST.m file

Set:
build_model = false;
solve_model = true;

and call MOST a second time, with your modified model as the input to MOST
There is currently a bug that would prevent this. I reported this bug in a separate earlier issue. The bug-fix is also mentioned there.

Note:
you have to add you new constraints and variables with the commands:
init_indexed_name and add_lin_constraint.
modifying the matrices: mdi.QP.A, mdi.QP.l, mdi.QP.u
would not work, because these matrices are over-written inside MOST.m

The developers of MOST.m may want to change that behavior, because generating mdi.QP takes a lot of time for large models.

a messy workaround is to build your own A, l and u and call the solver manually and outside most.m, that is:

if UC
[mdo.QP.x, mdo.QP.f, mdo.QP.exitflag, mdo.QP.output, mdo.QP.lambda ] = ...
miqps_matpower( mdi.QP.H, mdi.QP.C, mdi.QP.A, ...
mdi.QP.l, mdi.QP.u, mdi.QP.xmin, mdi.QP.xmax, ...
[], mdi.QP.vtype, mdo.QP.opt);
else
[mdo.QP.x, mdo.QP.f, mdo.QP.exitflag, mdo.QP.output, mdo.QP.lambda ] = ...
qps_matpower( mdi.QP.H, mdi.QP.C, mdi.QP.A, ...
mdi.QP.l, mdi.QP.u, mdi.QP.xmin, mdi.QP.xmax, ...
[], mdo.QP.opt);
end

I am currently working on a few papers and have already implemented several cases of custom constraints, new variables and new costs.
Once the paper is published, I'll share these along with a brief explanation.
An example of a constraint which isn't currently supported is:

  • Minimum-up-time and minimum-down-time are already implemented

but there is no constraint for: maximum-up-time!

  • Prevent two machines from being committed together at the same time
    i.e. u_1 + u_2 <= 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading MOST.m and the existing init_indexed_name and add_lin_constraint paths. Trace how the model is built and how mdi.QP.A, mdi.QP.l, and mdi.QP.u are regenerated, then review the separate earlier bug report referenced in the issue. Done would mean a decided design and documented support for user-defined variables, constraints, and costs without relying on manual solver calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
matlab
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.