Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Add slew constraints using a lazy constraint callback #65

Merged
merged 12 commits into from
May 28, 2021

Conversation

lpsinger
Copy link
Contributor

  • Add properties to the Mission class for overhead, slew velocity, and slew acceleration.
  • Change the observation time from a binary decision variable to a continuous one.
  • Implement the position-dependent slew constraints using a lazy constraint callback to keep the problem size manageable.

@lpsinger lpsinger requested a review from mcoughlin May 10, 2021 03:52
@lpsinger
Copy link
Contributor Author

Note: merge #64 first.

@lpsinger lpsinger marked this pull request as draft May 10, 2021 03:52
@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

Merging #65 (35d188c) into main (f189d26) will decrease coverage by 0.38%.
The diff coverage is 21.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
- Coverage   32.71%   32.32%   -0.39%     
==========================================
  Files          32       34       +2     
  Lines        1397     1553     +156     
==========================================
+ Hits          457      502      +45     
- Misses        940     1051     +111     
Impacted Files Coverage Δ
dorado/scheduling/scripts/main.py 12.64% <0.00%> (+3.24%) ⬆️
...rado/scheduling/schedulers/continuous_time_slew.py 12.79% <12.79%> (ø)
dorado/scheduling/schedulers/discrete_time.py 15.51% <15.51%> (ø)
dorado/scheduling/schedulers/__init__.py 39.53% <33.33%> (-7.84%) ⬇️
dorado/scheduling/mission.py 93.75% <85.71%> (-2.25%) ⬇️
dorado/scheduling/_slew.py 86.66% <100.00%> (+36.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f189d26...35d188c. Read the comment docs.

@lpsinger
Copy link
Contributor Author

Here's an example invocation that demonstrates the new slew constraints:

$ dorado-scheduling examples/6.fits --roll-step '90 deg' --timeout 600 --skygrid-method sinusoidal --skygrid-step '50 deg2' --nside 256 -o examples/6.ecsv
$ cat examples/6.ecsv
# %ECSV 0.9
# ---
# datatype:
# - {name: time, datatype: string, description: Start time of observation}
# - {name: exptime, unit: min, datatype: float64, description: Exposure time}
# - {name: location.x, unit: km, datatype: float64, description: Location of the spacecraft}
# - {name: location.y, unit: km, datatype: float64, description: Location of the spacecraft}
# - {name: location.z, unit: km, datatype: float64, description: Location of the spacecraft}
# - {name: center.ra, unit: deg, datatype: float64}
# - {name: center.dec, unit: deg, datatype: float64}
# - {name: roll, unit: deg, datatype: float64, description: 'Roll angle of spacecraft, position angle of FOV'}
# meta:
#   __serialized_columns__:
#     center:
#       __class__: astropy.coordinates.sky_coordinate.SkyCoord
#       __info__: {description: Pointing of the center of the spacecraft's FOV}
#       dec: !astropy.table.SerializedColumn
#         __class__: astropy.coordinates.angles.Latitude
#         unit: &id001 !astropy.units.Unit {unit: deg}
#         value: !astropy.table.SerializedColumn {name: center.dec}
#       frame: icrs
#       ra: !astropy.table.SerializedColumn
#         __class__: astropy.coordinates.angles.Longitude
#         unit: *id001
#         value: !astropy.table.SerializedColumn {name: center.ra}
#         wrap_angle: !astropy.coordinates.Angle
#           unit: *id001
#           value: 360.0
#       representation_type: spherical
#     location:
#       __class__: astropy.coordinates.earth.EarthLocation
#       __info__: {description: Location of the spacecraft}
#       ellipsoid: WGS84
#       x: !astropy.table.SerializedColumn
#         __class__: astropy.units.quantity.Quantity
#         __info__: {description: Location of the spacecraft}
#         unit: &id002 !astropy.units.Unit {unit: km}
#         value: !astropy.table.SerializedColumn {name: location.x}
#       y: !astropy.table.SerializedColumn
#         __class__: astropy.units.quantity.Quantity
#         __info__: {description: Location of the spacecraft}
#         unit: *id002
#         value: !astropy.table.SerializedColumn {name: location.y}
#       z: !astropy.table.SerializedColumn
#         __class__: astropy.units.quantity.Quantity
#         __info__: {description: Location of the spacecraft}
#         unit: *id002
#         value: !astropy.table.SerializedColumn {name: location.z}
#     time:
#       __class__: astropy.time.core.Time
#       __info__: {description: Start time of observation}
#       format: isot
#       in_subfmt: '*'
#       out_subfmt: '*'
#       precision: 3
#       scale: utc
#       value: !astropy.table.SerializedColumn {name: time}
#   cmdline: /Users/lpsinger/Library/Caches/pypoetry/virtualenvs/dorado-scheduling-SFXHA12M-py3.8/bin/dorado-scheduling examples/6.fits
#     --roll-step 90 deg --timeout 600 --skygrid-method sinusoidal --skygrid-step 50 deg2 --nside 256 -o examples/6.ecsv
#   prob: 0.8908575824921298
#   real: 417.721768929
#   status: OPTIMAL_SOLUTION
#   sys: 18.965289
#   user: 391.320404
# schema: astropy-2.0
time exptime location.x location.y location.z center.ra center.dec roll
2012-05-02T18:58:32.699 10.0 -1751.6172079535218 -4316.900611397083 5223.012730741018 117.55102040816325 20.769230769230763 0.0
2012-05-02T19:09:14.699 10.0 -973.3043830130079 92.98057935785886 6927.010019294085 134.11764705882354 13.846153846153847 0.0
2012-05-02T19:24:18.324 10.0 1378.4783464318048 5551.147749749632 4036.794250930597 134.11764705882354 6.923076923076917 0.0
2012-05-02T19:35:44.699 10.0 2759.8342256807664 6388.449956560732 -817.8327909369189 90.0 -55.38461538461539 0.0
2012-05-02T19:46:26.699 10.0 2684.8918143840388 4086.573422741732 -5022.955119551435 66.66666666666666 -62.30769230769231 0.0
2012-05-02T19:57:08.699 10.0 1086.7009064685772 -0.4316301257354248 -6925.754617122366 80.0 -62.30769230769231 0.0
2012-05-02T20:07:50.699 10.0 -1379.4305614984585 -3897.0288989888454 -5661.511726980589 53.333333333333336 -62.30769230769231 0.0
2012-05-02T20:18:32.699 10.0 -3488.629943406112 -5803.880422692486 -1804.1324921006578 78.75 -55.38461538461539 0.0
$ dorado-scheduling-animate examples/6.fits examples/6.ecsv examples/6.gif --nside 256

6

Copy link
Collaborator

@mcoughlin mcoughlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really nice. I had gotten partway there ;) Looks ready to merge after the rebase to pick up the nonzero_intervals function.

@lpsinger
Copy link
Contributor Author

I had gotten partway there ;)

Do you have any insights on the MIP formulation from your work on the problem?

@lpsinger lpsinger force-pushed the slew-constraints-mp branch 2 times, most recently from 826cc54 to 4f98f16 Compare May 10, 2021 16:02
@lpsinger lpsinger force-pushed the slew-constraints-mp branch 2 times, most recently from 481195e to 942c8c4 Compare May 21, 2021 01:49
@lpsinger
Copy link
Contributor Author

lpsinger commented May 21, 2021

@mcoughlin, this is ready for review now.

Both models (discrete-time and continuous-time-slew) are now kept in the tree, under dorado.scheduling.schedulers.

Output from --scheduler=continuous-time-slew

6-continuous-time-slew

Output from --scheduler=discrete-time

6-discrete-time

@mcoughlin
Copy link
Collaborator

Can we give Alexander a shot at giving it a real look @lpsinger?

@lpsinger
Copy link
Contributor Author

Can we give Alexander a shot at giving it a real look @lpsinger?

Yes, please! What's Alexander's GitHub handle, by the way?

@mcoughlin
Copy link
Collaborator

@lpsinger It is @criswellalexander.

@lpsinger lpsinger marked this pull request as ready for review May 21, 2021 13:19
@lpsinger lpsinger force-pushed the slew-constraints-mp branch 4 times, most recently from 5b3f1c6 to 70fcd0f Compare May 25, 2021 03:04
* Add properties to the Mission class for overhead, slew
  velocity, and slew acceleration.
* Change the observation time from a binary decision variable to
  a continuous one.
* Implement the position-dependent slew constraints using a lazy
  constraint callback to keep the problem size manageable.
It seems to speed things up by about 2x.
This is normally done implicitly by CPLEX in its presolve, but
that was disabled by the lazy constraints.
Each has strengths and weaknesses. In this early stage, it is valuable
to keep around both.
Dorado uses a frame transfer CCD, so there is effectively no
readout overhead.
@criswellalexander
Copy link

I looked over the code and did some runs with both the discrete-time and continuous-time-slew settings, everything looks good and works as I'd expect!

@mcoughlin
Copy link
Collaborator

I looked through it as well. Can I merge @lpsinger ?

@lpsinger
Copy link
Contributor Author

One sec, there is a broken unit test. Let me fix that.

@lpsinger
Copy link
Contributor Author

Tests are passing now! @mcoughlin, would you do the honors?

@mcoughlin
Copy link
Collaborator

Honored I am!

@mcoughlin mcoughlin merged commit c3ceb9d into nasa:main May 28, 2021
@lpsinger lpsinger deleted the slew-constraints-mp branch May 28, 2021 19:11
@lpsinger
Copy link
Contributor Author

John Cena tipping hat

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants