Skip to content

Commit 2654e6d

Browse files
phc1990Pau Hebrero
andauthored
[draft] perf: improve Segment Chunk strategy performance (#644)
* perf: improve Segment Chunk strategy performance * refactor: apply PR suggestions --------- Co-authored-by: Pau Hebrero <pau.hebrero@gmail.com>
1 parent 77b16b3 commit 2654e6d

File tree

1 file changed

+17
-1
lines changed
  • src/OpenSpaceToolkit/Astrodynamics/Trajectory

1 file changed

+17
-1
lines changed

src/OpenSpaceToolkit/Astrodynamics/Trajectory/Segment.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,24 @@ Segment::Solution Segment::solve(
788788
// function will append them a second time.
789789
segmentStates.add(Array<State>(coastSolution.states.begin() + 1, coastSolution.states.end()));
790790

791+
Instant maximumManeuverSolutionInstant = maximumInstant;
792+
793+
if (maneuverConstraints_.maximumDuration.isDefined() &&
794+
maneuverConstraints_.maximumDurationStrategy == MaximumManeuverDurationViolationStrategy::Chunk)
795+
{
796+
// Performance when considering a maximum maneuver duration constraint for the "Chunk" strategy
797+
// can be optimized by eliminating redundant solver iterations and unnecessary trimming.
798+
//
799+
// Since the "Chunk" strategy does not need to know when the burn is going to end, we can safely
800+
// assume that the burn (or chunk for that matter) should not take longer than said maximum duration.
801+
maximumManeuverSolutionInstant = std::min(
802+
segmentStates.accessLast().accessInstant() + maneuverConstraints_.maximumDuration,
803+
maximumManeuverSolutionInstant
804+
);
805+
}
806+
791807
const Segment::Solution maneuverSolution =
792-
solveUntilThrusterOff_(segmentStates.accessLast(), maximumInstant, thrusterDynamics);
808+
solveUntilThrusterOff_(segmentStates.accessLast(), maximumManeuverSolutionInstant, thrusterDynamics);
793809

794810
if (maneuverSolution.states.getSize() <= 2)
795811
{

0 commit comments

Comments
 (0)