drake icon indicating copy to clipboard operation
drake copied to clipboard

Bind GcsTrajectoryOptimization::EstimateComplexity

Open cohnt opened this issue 1 year ago • 8 comments

Very tiny PR -- I wanted to use this function for something in python, and figured there's a chance others might want to as well.


This change is Reviewable

cohnt avatar Jan 31 '24 23:01 cohnt

Do you have a feature reviewer in mind for this, @cohnt ?

sherm1 avatar Feb 01 '24 02:02 sherm1

No preference. It's such a tiny change, pretty much anyone could do it? Is this an instance of a "single reviewer okay" PR?

cohnt avatar Feb 01 '24 02:02 cohnt

wait... why do you want to use this function? I actually don't like that function; and thought it was only there for testing purposes?

RussTedrake avatar Feb 01 '24 03:02 RussTedrake

As I'm running multiple GCS programs of different sizes and levels of connectivity, I wanted a better way to compare their complexity. It's not super important, but since it was publicly available in the C++, I figured I could add a quick Python binding.

cohnt avatar Feb 01 '24 13:02 cohnt

With my platform reviewer hat on:

At the moment, this PR is internally inconsistent because it binds a function for end-users whose docs say it's not intended for end-users. (The API comment is somewhat ambiguous, though.)

I think we're on a saddle with two ways out:

(1) Clarify the ambiguous API comment by removing the "for regression testing purposes" text. Add the Python binding. Given https://github.com/RobotLocomotion/drake/pull/19444#pullrequestreview-1464885672, it seems like you might also need to convince Russ about a better function name, and/or an improved implementation.

(2) Clarify the ambiguous API comment by strengthening "for regression testing purposes" to more directly say "Internal use only", and hiding the function from Doxygen. If y'all decide to go this route, LMK and I can prepare a new PR with the right Doxygen giblets for this approach.

\CC @ggould-tri FYI as reviewer on the prior PR.

jwnimmer-tri avatar Feb 01 '24 17:02 jwnimmer-tri

I agree with Russ that the function should be improved. Full disclosure, in my fork I use a binding of this function to set the number of super basics SNOPT should use. There is use in an improved version that is not only for internal use.

wrangelvid avatar Feb 01 '24 18:02 wrangelvid

The function was initially introduced because David was PR'ing an implementation-only change (no API change, no functionality change), citing that the problem formulation got smaller, and we wanted a strategy to confirm that in a test.

The conversation in this thread suggests to me that it is already being interpreted as having a meaningful correspondence with GCS solve times. I'm not at all convinced that it does. (I could be convinced, and could definitely believe that it would be valuable if that correlation was available). My first preference would be to become convinced. My second preference would be to mark it explicitly internal (or even remove it entirely).

RussTedrake avatar Feb 18 '24 13:02 RussTedrake

Having some sort of measure of the complexity of a mathematical program is super useful. Even if it's only weakly monotonic, being able to compare two programs and say "this one is much harder than the other" is very nice. It doesn't have to be this method, and if there's a better method, I'm happy to use it. But for now, this is what's in GCS.

cohnt avatar Feb 26 '24 19:02 cohnt

I no longer need this feature, so I'm fine with closing the PR.

cohnt avatar Jun 05 '24 13:06 cohnt

Closing per author's note above; reopen or duplicate the next time someone wants this feature.

ggould-tri avatar Jun 05 '24 13:06 ggould-tri