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

Make sequencer constraint #378

Merged
merged 29 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ebfa58
Make sequencer constraint
jermainegug Jan 17, 2018
497b4dd
*can't use scheduler here (try observation)
jermainegug Jan 17, 2018
7623a69
*edit
jermainegug Jan 17, 2018
beac373
Change names
jermainegug Jan 17, 2018
2260d04
Start making test for constraint
jermainegug Jan 17, 2018
b9f7877
Edits
jermainegug Jan 17, 2018
440a466
*fix indent typo
jermainegug Jan 17, 2018
f4ab18e
*put return into function
jermainegug Jan 18, 2018
cfce422
*import OrderedDict
jermainegug Jan 18, 2018
c8e118e
*initialize observed_list to be empty
jermainegug Jan 18, 2018
0c72b44
Couple fixups
jermainegug Jan 18, 2018
86c6f55
*not checking observation.field
jermainegug Jan 18, 2018
71735ab
*try for loop
jermainegug Jan 18, 2018
4548b9b
*fix typos
jermainegug Jan 18, 2018
8106c11
*put print to see what observed_list looks like
jermainegug Jan 18, 2018
dcfba36
Hopefully final fix!
jermainegug Jan 18, 2018
aa6abe0
*try dict instead of OrderedDict
jermainegug Jan 18, 2018
b50a07d
*change back to OrderedDict
jermainegug Jan 18, 2018
e33509e
*add sentence in class description
jermainegug Jan 18, 2018
773d2b3
*don't need import OrderedDict in constraint.py
jermainegug Jan 18, 2018
25b1a3e
*avoid loop
jermainegug Jan 18, 2018
5b7b6fe
Edit the scheduler playground
jermainegug Jan 18, 2018
5c0b274
Fixing issue with observed_list
jermainegug Jan 19, 2018
732e041
Merge branch 'develop' into make-new-constraint
jermainegug Jan 19, 2018
fd78307
*pass observed_list into get_score for already visited constraint
jermainegug Jan 20, 2018
058bc65
*put observed_list into get_score
jermainegug Jan 20, 2018
f2cba6c
Undo commit
jermainegug Jan 20, 2018
37c9616
*update shceduler notebook
jermainegug Jan 21, 2018
8072579
*use field instead of seq_time
jermainegug Jan 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pocs/scheduler/constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,23 @@ def get_score(self, time, observer, observation, **kwargs):

def __str__(self):
return "Moon Avoidance"

class AlreadyVisited(BaseConstraint):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def get_score(self, time, observer, observation, **kwargs):
veto = False
score = self._score

target = observation.field
observed_list = kwargs['observed_list']
Copy link
Member

Choose a reason for hiding this comment

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

For normal operations you'll still want to pull from observation.observed_list as that's how the scheduler builds it up. So do akwargs.get('observed_list', observation.observed_list) here.


if target in observed_list:
veto = True

return veto, score * self.weight

def __str__(self):
return "Already Visited"
22 changes: 22 additions & 0 deletions pocs/tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pocs.scheduler.constraint import BaseConstraint
from pocs.scheduler.constraint import Duration
from pocs.scheduler.constraint import MoonAvoidance
from pocs.scheduler.constraint import AlreadyVisited


@pytest.fixture
Expand Down Expand Up @@ -197,3 +198,24 @@ def test_moon_avoidance(observer):

assert veto1 is False and veto2 is False
assert score2 > score1


def test_already_visited(observer):
avc = AlreadyVisited()

time = Time('2016-08-13 10:00:00')

observation1 = Observation(Field('HD189733', '20h00m43.7135s +22d42m39.0645s')) # HD189733
observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16
observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik

observed_list = OrderedDict()

observed_list[observation1.seq_time] = observation1
observed_list[observation2.seq_time] = observation2

veto1, score1 = avc.get_score(time, observer, observation1, observed_list=observed_list)
Copy link
Member

Choose a reason for hiding this comment

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

An alternative to passing the observed_list and using the kwargs as above is to just alter the observer.observed_list here.

veto2, score2 = avc.get_score(time, observer, observation3, observed_list=observed_list)

assert veto1 is True
assert veto2 is False