Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Optuna Sensor Manager #1106

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add Optuna Sensor Manager #1106

wants to merge 4 commits into from

Conversation

csherman-dstl
Copy link
Contributor

Add a new sensor manager that utilises the optuna module to determine the best action available within a given timeout period.

@csherman-dstl csherman-dstl requested a review from a team as a code owner December 10, 2024 16:04
@csherman-dstl csherman-dstl requested review from hpritchett-dstl and orosoman-dstl and removed request for a team December 10, 2024 16:04
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 80.39216% with 10 lines in your changes missing coverage. Please review.

Project coverage is 93.66%. Comparing base (0b20e96) to head (eb2b456).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
stonesoup/sensormanager/optuna.py 80.39% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1106      +/-   ##
==========================================
- Coverage   93.72%   93.66%   -0.06%     
==========================================
  Files         214      215       +1     
  Lines       14004    14055      +51     
  Branches     1925     1934       +9     
==========================================
+ Hits        13125    13165      +40     
- Misses        627      633       +6     
- Partials      252      257       +5     
Flag Coverage Δ
integration 66.64% <0.00%> (-0.23%) ⬇️
unittests 90.90% <80.39%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sdhiscocks
Copy link
Member

The warnings below were produced by the tests. Looks like it results in the last step being missed out.

Looks like the original numbers check out correct as floating points, but the way optuna checks is by converting to strings and decimals, and guess then rounding error occurs. Could either do something similar and ensure to round high value up; or just adding on a small number would probably do (some small multiple of step) but then warning would need supressing.

=============================== warnings summary ===============================
stonesoup/sensormanager/tests/test_optuna.py::test_optuna_manager
  /home/circleci/project/venv/lib/python3.12/site-packages/optuna/distributions.py:693: UserWarning:
  
  The distribution is specified by [-0.7853981633974483, 11.780972450961723] and step=1.5707963267948966, but the range is not divisible by `step`. It will be replaced by [-0.7853981633974483, 10.210176124166829].

stonesoup/sensormanager/tests/test_optuna.py::test_optuna_manager
  /home/circleci/project/venv/lib/python3.12/site-packages/optuna/distributions.py:693: UserWarning:
  
  The distribution is specified by [-3.9269908169872414, 8.63937979737193] and step=1.5707963267948966, but the range is not divisible by `step`. It will be replaced by [-3.9269908169872414, 7.0685834705770345].

stonesoup/sensormanager/tests/test_optuna.py::test_optuna_manager
  /home/circleci/project/venv/lib/python3.12/site-packages/optuna/distributions.py:693: UserWarning:
  
  The distribution is specified by [-5.497787143782138, 7.0685834705770345] and step=1.5707963267948966, but the range is not divisible by `step`. It will be replaced by [-5.497787143782138, 5.497787143782138].

stonesoup/sensormanager/tests/test_optuna.py::test_optuna_manager
  /home/circleci/project/venv/lib/python3.12/site-packages/optuna/distributions.py:693: UserWarning:
  
  The distribution is specified by [-7.068583470577035, 5.497787143782137] and step=1.5707963267948966, but the range is not divisible by `step`. It will be replaced by [-7.068583470577035, 3.9269908169872414].

stonesoup/sensormanager/tests/test_optuna.py::test_optuna_manager
  /home/circleci/project/venv/lib/python3.12/site-packages/optuna/distributions.py:693: UserWarning:
  
  The distribution is specified by [-8.639379797371932, 3.9269908169872405] and step=1.5707963267948966, but the range is not divisible by `step`. It will be replaced by [-8.639379797371932, 2.3561944901923444].

Copy link
Contributor

@nperree-dstl nperree-dstl left a comment

Choose a reason for hiding this comment

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

Looks good and works well for me!

If it doesn't break anything it might be worth adding the action_from_value method to the RealNumberActionGenerator, as otherwise I think it only exists in the DwellActionGenerator. (this is also a problem for both of the scipy sensor managers so there might be a reason we didn't, I can't remember!)

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

Successfully merging this pull request may close these issues.

3 participants