mdolab / mdolab/pyoptsparse

Support calculation of only active constraint derivatives

Open
#439 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
270
Forks
123
Avg merge
1d 18h
Merged PRs (30d)
3

Description

Description of feature

NLPQLP supports only computing the derivatives of the constraints that it currently considers active, which it tells you through the active array that it passes to pyoptsparse nlgrad function. It would be great if we could support this capability in pyOptSparse as it has the potential to speed up problems with many constraints.

Image

Image

To demonstrate, NLPQLP converges just fine with the following:

def nlgrad(m, me, mmax, n, f, g, df, dg, x, active, wa):
    gobj, gcon, fail = self._masterFunc(x, ["gobj", "gcon"])
    df[0:n] = gobj.copy()
    # Only copy the active constraints
    activeConIndices = np.where(active[0:m] != 0)[0]
    dg[activeConIndices, 0:n] = -gcon.copy()[activeConIndices]
    return df, dg

Although clearly this implementation doesn't actually save any time since it still computes the entire constraint jacobian.

Potential solution

The implementation would be quite involved, requiring at least the following:

  • Mapping the active constraints as seen by NLPQLP back to form defined by the user (e.g undoing the conversion from two-sided to one-sided constraints)
  • Determining a way to pass the active constraint information to the user's sens function (e.g sens(self, xdict, funcs, activeCon)), and doing so in a way they can still use the current sens signature (sens(self, xdict, funcs))
  • Determining a standard for how the user is expected to pass back the active constraint values (I can see this being complicated for large sparse constraints if we want to support only computing the derivatives for the active entries of those constraints)

Contributor guide

No contributing guide indexed for this repository

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 tracing how NLPQLP's active array reaches the pyOptSparse nlgrad function, then inspect the user sens interface described in the issue. Map the constraint transformations and define how active information and returned derivatives would be represented while preserving the current sens signature; the work is done when active-only derivative computation is supported end to end.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, performance
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.