Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
8365331
add_velocity function
PalkaPuri Aug 7, 2024
e2ee500
velocity predictor WIP
PalkaPuri Aug 8, 2024
6a19ae4
wip
PalkaPuri Aug 8, 2024
b5dde8a
format/lint
PalkaPuri Aug 8, 2024
a923457
specify forager column as int
PalkaPuri Aug 12, 2024
8cc4111
add warning
PalkaPuri Aug 12, 2024
892da93
format/lint
PalkaPuri Aug 12, 2024
f675d23
rename f,t for clarity
PalkaPuri Aug 13, 2024
1ee7caa
rerun notebook
PalkaPuri Aug 13, 2024
fcd34b2
add docstrings
PalkaPuri Aug 13, 2024
dc950c2
format/lint
PalkaPuri Aug 13, 2024
205235f
use inbuilt function for gaussian pdf
PalkaPuri Aug 13, 2024
b476a17
merge changes from pp-collab2-compute-velocity
PalkaPuri Aug 13, 2024
045e7d0
updated visualization
PalkaPuri Aug 13, 2024
05b3d90
add handling of nan values in visualization
PalkaPuri Aug 15, 2024
5774858
add _generate_pairwise_copying predictor
PalkaPuri Aug 15, 2024
41a7787
format/lint
PalkaPuri Aug 15, 2024
ab6ee7e
type hints
PalkaPuri Aug 15, 2024
47679f3
add pairwise predictor and animation function
PalkaPuri Aug 21, 2024
fac3f10
change velocity to backward looking
PalkaPuri Aug 21, 2024
ddf4572
Merge branch 'pp-collab2-compute-velocity' of https://github.com/Basi…
PalkaPuri Aug 21, 2024
4b242d8
docstrings and type hints
PalkaPuri Aug 21, 2024
82223c0
generate function and typehints
PalkaPuri Aug 21, 2024
11f5dce
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 21, 2024
0dec71b
fixed naming, nan handling
PalkaPuri Aug 21, 2024
ea399b2
refactoring
PalkaPuri Aug 22, 2024
9a2ec97
vicsek wip
PalkaPuri Aug 23, 2024
033e565
update normalization of velocity predictors
PalkaPuri Aug 26, 2024
9c6854b
distance_to_next_move WIP
PalkaPuri Aug 26, 2024
8bfa2d0
Merge branch 'pp-collab2-vicsek-predictor' of https://github.com/Basi…
PalkaPuri Aug 26, 2024
e61915f
added alternates for distance_to_next_pos
PalkaPuri Aug 26, 2024
e79917e
lint/format
PalkaPuri Aug 26, 2024
ab7df53
updated nb example
PalkaPuri Aug 26, 2024
21e0361
update scores wip
PalkaPuri Aug 27, 2024
fca3235
merge rafal's changes
PalkaPuri Aug 27, 2024
d9cadcf
absolute paths for imports in modules
PalkaPuri Aug 27, 2024
3999139
update module to allow chnaging n
PalkaPuri Aug 27, 2024
540b11b
renaming
PalkaPuri Aug 27, 2024
a7b0495
format
PalkaPuri Aug 27, 2024
d0018bd
trace code in place
rfl-urbaniak Aug 27, 2024
319aa97
rename n
PalkaPuri Aug 28, 2024
cf3d543
merge staging-collab-2
PalkaPuri Aug 28, 2024
e47d161
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 29, 2024
92a1957
add derive_predictors
PalkaPuri Aug 29, 2024
fd2a3f3
test inference wip
PalkaPuri Aug 29, 2024
d573538
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Aug 29, 2024
e2d3615
derive WIP
PalkaPuri Aug 29, 2024
f897604
test inference pipeline
PalkaPuri Aug 29, 2024
5230e77
format/lint
PalkaPuri Aug 29, 2024
e8dba19
format again
PalkaPuri Aug 29, 2024
a0f024c
one more format
PalkaPuri Aug 29, 2024
e07b3ff
lint
PalkaPuri Aug 29, 2024
5faaa13
format
PalkaPuri Aug 29, 2024
b01c8cf
adding doc to local_windows WIP
PalkaPuri Aug 29, 2024
e7bfeaf
small typos in docstrings
rfl-urbaniak Aug 30, 2024
4476c6b
added predictor time to logging
rfl-urbaniak Aug 30, 2024
bcbd8d6
added time to score logging
rfl-urbaniak Aug 30, 2024
72d28f4
time to logging, a few typos
rfl-urbaniak Aug 30, 2024
8d6a2ce
format lint
rfl-urbaniak Aug 30, 2024
5c70d1f
refactored proximity
rfl-urbaniak Aug 30, 2024
eb406a7
removed old proximity code
rfl-urbaniak Aug 30, 2024
bfbf187
format lint
rfl-urbaniak Aug 30, 2024
065518c
refactored trace
rfl-urbaniak Aug 30, 2024
20b89c1
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Aug 30, 2024
bdc5bff
added generate food to init
rfl-urbaniak Aug 30, 2024
0de9af7
format, lint
rfl-urbaniak Aug 30, 2024
1f0e506
update parameter names in docstring
PalkaPuri Sep 3, 2024
a7c55cc
explanation of score_kwargs
PalkaPuri Sep 3, 2024
b14029d
update next_step_score notebook
PalkaPuri Sep 3, 2024
2b8126f
update warning and add docstring to dataObject
PalkaPuri Sep 3, 2024
f00ce02
removing reusing velocity warning
PalkaPuri Sep 3, 2024
4d11e85
removed individual drop warning, add to derive_predictors_and_scores
PalkaPuri Sep 3, 2024
66688b8
lint/format
PalkaPuri Sep 3, 2024
c3f875e
fix bug in test
PalkaPuri Sep 3, 2024
d7fe531
format
PalkaPuri Sep 3, 2024
21083e8
Merge branch 'pp-collab2-derivepredictors' into pp-collab2-housekeeping
PalkaPuri Sep 3, 2024
2b8ecb2
local_windows update constraint implementation, add docstring
PalkaPuri Sep 3, 2024
5df34c7
rename variables
PalkaPuri Sep 3, 2024
62f0cb2
filter_by_distance update constraint implementation
PalkaPuri Sep 3, 2024
728a182
remove fps argument from subsampling func
PalkaPuri Sep 3, 2024
c7bc9bf
velocity- rename predictorID, update constraint implementation, docst…
PalkaPuri Sep 3, 2024
b583275
ensure all test notebooks run
PalkaPuri Sep 3, 2024
a621300
format/lint WIP
PalkaPuri Sep 3, 2024
e33c5f8
Merge branch 'ru-new-trace' into pp-collab2-housekeeping
PalkaPuri Sep 3, 2024
1b28cc3
ensure rafals nbs run
PalkaPuri Sep 3, 2024
c4ddd34
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Sep 4, 2024
2d9829e
type hints for kwargs in constraint func
PalkaPuri Sep 4, 2024
2ea9f12
add collab2 notebooks to automatic testing
PalkaPuri Sep 4, 2024
953558e
small fixes to local_windows.py docstrings
rfl-urbaniak Sep 4, 2024
f75ec48
interpunction in filtering.py
rfl-urbaniak Sep 4, 2024
d9249c1
proximity notebook now works
rfl-urbaniak Sep 5, 2024
575db78
wip
rfl-urbaniak Sep 5, 2024
2bd0546
fixed trace and derivation notebooks
rfl-urbaniak Sep 5, 2024
5913050
resolved type hinting problems
rfl-urbaniak Sep 5, 2024
f3f7e4f
fix some bugs
PalkaPuri Sep 5, 2024
bba492b
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
PalkaPuri Sep 5, 2024
dd1816c
notebook issue fix
PalkaPuri Sep 5, 2024
b4edb96
fix type hint in proximity
PalkaPuri Sep 5, 2024
ca693a8
Merge branch 'pp-collab2-housekeeping' of https://github.com/BasisRes…
rfl-urbaniak Sep 5, 2024
b88937e
grid_constraint_params updated to dict
PalkaPuri Sep 9, 2024
35f9131
interaction_constraint_params updated to dict
PalkaPuri Sep 9, 2024
1bcf668
make sure all notebooks pass + format/lint
PalkaPuri Sep 9, 2024
5572734
lint
rfl-urbaniak Sep 9, 2024
59e6215
lint
rfl-urbaniak Sep 9, 2024
f9b92da
lint
rfl-urbaniak Sep 9, 2024
bdd9965
lint
rfl-urbaniak Sep 9, 2024
1e1a548
lint
rfl-urbaniak Sep 9, 2024
5467b05
lint
rfl-urbaniak Sep 9, 2024
cc63147
lint
rfl-urbaniak Sep 9, 2024
c2f4c82
suspended old velocity test
rfl-urbaniak Sep 9, 2024
954d9e5
rhf old update
rfl-urbaniak Sep 17, 2024
032b3f4
Merge branch 'ru-random-hungry-2' of https://github.com/BasisResearch…
rfl-urbaniak Sep 17, 2024
944b20a
re-ran hungry and random foragers
rfl-urbaniak Sep 17, 2024
5780fef
following foragers replicated
rfl-urbaniak Sep 17, 2024
4ee8c47
format, lint
rfl-urbaniak Sep 18, 2024
1d31c6b
change to sublinear
rfl-urbaniak Sep 18, 2024
f0293fb
fixing velocity_predicts WIP
rfl-urbaniak Sep 18, 2024
e3d75c6
updated trace_predictor
rfl-urbaniak Sep 18, 2024
c1c0b8b
suspend animations in velocity predictors
rfl-urbaniak Sep 18, 2024
5205da4
added access predictor
rfl-urbaniak Sep 19, 2024
ec21ab4
updated random with access
rfl-urbaniak Sep 19, 2024
233c693
updateg hungry foragers
rfl-urbaniak Sep 19, 2024
bab23a2
updated followers with access
rfl-urbaniak Sep 19, 2024
b349262
format, lint
rfl-urbaniak Sep 19, 2024
2e3321c
communication WIP
rfl-urbaniak Sep 19, 2024
9b6e058
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Sep 19, 2024
07c231f
wip
rfl-urbaniak Sep 19, 2024
52b339b
fixed lint
rfl-urbaniak Sep 19, 2024
920b509
WIP
rfl-urbaniak Sep 19, 2024
22104de
fixed imports in random foragers
rfl-urbaniak Sep 19, 2024
acc6d96
WIP
rfl-urbaniak Sep 19, 2024
f20a472
fixing init
rfl-urbaniak Sep 19, 2024
e313810
communication predictor notebook functional
rfl-urbaniak Sep 19, 2024
605ed17
format, lint
rfl-urbaniak Sep 19, 2024
f3a6aa1
restored init fix
rfl-urbaniak Sep 19, 2024
8f61e4e
bump pyro to 1.9.1
rfl-urbaniak Sep 20, 2024
e0dfbaf
revert (chirho), remove deterministic from rendering
rfl-urbaniak Sep 20, 2024
77752a3
Merge branch 'ru-random-hungry-2' of https://github.com/BasisResearch…
rfl-urbaniak Sep 20, 2024
2548754
pkl to gitignore
rfl-urbaniak Sep 20, 2024
bcc7617
locust wip
rfl-urbaniak Sep 24, 2024
1ba8214
locust WIP
rfl-urbaniak Sep 24, 2024
05b2ce3
locust wip
rfl-urbaniak Sep 27, 2024
52d0f14
Some polishing of the random/hungry/followers notebooks and fixing st…
dimkab Oct 2, 2024
9ee6bad
Merge branch 'ru-random-hungry-2' of https://github.com/BasisResearch…
rfl-urbaniak Oct 2, 2024
f8cb283
format
rfl-urbaniak Oct 2, 2024
002144e
pin cleanup package versions
rfl-urbaniak Oct 2, 2024
ce347ba
upgrade and pin nbqa
rfl-urbaniak Oct 2, 2024
a52eb2b
suspend outdated velocity test
rfl-urbaniak Oct 2, 2024
4de6bab
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Oct 3, 2024
b683cef
missing import for generate_communication_predictor in __init__.py
dimkab Oct 3, 2024
cd8f8c5
decoupled communicator simulations from collab 1
rfl-urbaniak Oct 5, 2024
ff4a04d
format lint
rfl-urbaniak Oct 5, 2024
686e384
ensure starts at 0 with communicators inference, re-run
rfl-urbaniak Oct 5, 2024
946c9f3
format, lint
rfl-urbaniak Oct 5, 2024
eddce38
Merge branch 'ru-communication' of https://github.com/BasisResearch/c…
rfl-urbaniak Oct 5, 2024
219fcf0
change framing to approximately the one in paper
rfl-urbaniak Oct 5, 2024
e664c6f
re-run locust, format, lint
rfl-urbaniak Oct 5, 2024
f26fdee
add next step exponential
PalkaPuri Oct 7, 2024
113f242
add rescaling
PalkaPuri Oct 7, 2024
3654da6
cp birds predictors derived
rfl-urbaniak Oct 8, 2024
6eeca70
wip
rfl-urbaniak Oct 8, 2024
c757691
update notebook wip
rfl-urbaniak Oct 10, 2024
34aecc6
wip
rfl-urbaniak Oct 10, 2024
d73506f
cp wip
rfl-urbaniak Oct 10, 2024
fa56d1f
cp wip
rfl-urbaniak Oct 12, 2024
feb7393
bayesian optimization for ducks
rfl-urbaniak Oct 13, 2024
7e773dd
ducks optimization
rfl-urbaniak Oct 15, 2024
09f3571
cp optimization wip
rfl-urbaniak Oct 16, 2024
9f3c30b
before central parks cleanup
rfl-urbaniak Oct 17, 2024
68b9512
reinstate proximity
rfl-urbaniak Oct 17, 2024
0c1d7ab
cp bnotebook revised
rfl-urbaniak Oct 17, 2024
bc193e9
format lint
rfl-urbaniak Oct 17, 2024
68bdaec
Merge branch 'staging-collab-2' of https://github.com/BasisResearch/c…
rfl-urbaniak Oct 17, 2024
bc0d5ca
added uninformed prior, format, lint
rfl-urbaniak Oct 17, 2024
6b5c22b
add bayesian opt to setup to pass CI
rfl-urbaniak Oct 17, 2024
b4dcacd
wip
rfl-urbaniak Oct 18, 2024
dadbc31
update gitignore
rfl-urbaniak Oct 18, 2024
e84e1d2
tests
rfl-urbaniak Oct 18, 2024
2924c20
Merge branch 'ru-simple-cp' of https://github.com/BasisResearch/colla…
rfl-urbaniak Oct 18, 2024
82c7897
merge from collab 2
rfl-urbaniak Oct 18, 2024
4983fe6
Merge branch 'pp-nextstep-exponential' of https://github.com/BasisRes…
rfl-urbaniak Oct 18, 2024
8ae5372
Merge remote-tracking branch 'origin/main' into pp-nextstep-exponential
PalkaPuri Dec 12, 2024
4f67200
fit merge
PalkaPuri Dec 12, 2024
02935f6
fix merge issues
PalkaPuri Dec 12, 2024
bf02691
add nextStepExponential and test
PalkaPuri Dec 12, 2024
a3b1755
format/lint
PalkaPuri Dec 12, 2024
169d93b
update notebook tests from main
rfl-urbaniak Dec 31, 2024
9db8434
Merge branch 'pp-nextstep-exponential' of https://github.com/BasisRes…
rfl-urbaniak Dec 31, 2024
ee3121e
Merge branch 'main' of https://github.com/BasisResearch/collab-creatu…
rfl-urbaniak Dec 31, 2024
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
2 changes: 1 addition & 1 deletion collab/foraging/toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
continuous_contribution,
)
from .next_step_score import ( # noqa: F401
_generate_nextStep_score,
generate_nextStep_score,
generate_nextStepExponential_score,
)
from .proximity import ( # noqa: F401; foragers_to_forager_distances,
generate_proximity_predictor,
Expand Down
81 changes: 81 additions & 0 deletions collab/foraging/toolkit/next_step_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,84 @@ def generate_nextStep_score(foragers_object: dataObject, score_name: str):
return _generate_nextStep_score(
foragers_object.foragers, foragers_object.local_windows, score_name, **params
)


def _generate_nextStepExponential_score(
foragers: List[pd.DataFrame],
local_windows: List[List[pd.DataFrame]],
score_name: str,
decay_length: Optional[float] = 1.0,
):
"""
A function that computes a score for how far grid points are from the next position of a forager,
using an exponential decay.
If the next position of the forager is unavailable, nan values are assigned to the scores.

:param foragers: list of DataFrames containing forager positions, grouped by forager index
:param local_windows: Nested list of DataFrames containing grid points to compute predictor over,
grouped by forager index and time
:param score_name: name of column to save the calculated nextStep scores under
:param decay_length: length scale of exponential decay

:return: Nested list of calculated scores, grouped by foragers and time
"""

num_foragers = len(foragers)
num_frames = len(foragers[0])
score = copy.deepcopy(local_windows)

for f in range(num_foragers):
for t in range(num_frames - 1):
if score[f][t] is not None:
x_new = foragers[f].at[t + 1, "x"]
y_new = foragers[f].at[t + 1, "y"]
if np.isfinite(x_new) and np.isfinite(y_new):
distance_to_next_step = np.sqrt(
(score[f][t]["x"] - x_new) ** 2
+ (score[f][t]["y"] - y_new) ** 2
)

score[f][t][score_name] = np.exp(
-distance_to_next_step / decay_length
)

# rescale over the grid
score[f][t][score_name] = (
score[f][t][score_name] - score[f][t][score_name].min()
) / (score[f][t][score_name].max() - score[f][t][score_name].min())
else:
score[f][t][score_name] = np.nan

# save nans for last frame
if score[f][num_frames - 1] is not None:
score[f][num_frames - 1][score_name] = np.nan

return score


def generate_nextStepExponential_score(foragers_object: dataObject, score_name: str):
"""
A wrapper function that computes nextStepExponential score only taking `foragers_object` as argument,
and calling `_generate_nextStepExponential_score` under the hood.

The next step score computes a score for how far grid points are from the next position of a forager,
using an exponential decay.
If the next position of the forager is unavailable, nan values are assigned to the scores.

The formula for the score is:
next_step_score(i,t,x,y) = exp(-d_nextStep/decay_length)
where d_nextStep is the distance of (x,y) grid point from the position of forager i
at time t+1

:param foragers_object: dataObject containing positional data, local_windows, score_kwargs
:param score_name : name of column to save the calculated nextStep scores under

:return: Nested list of calculated scores, grouped by foragers and time

Keyword arguments:
:param decay_length: length scale of exponential decay
"""
params = foragers_object.score_kwargs[score_name]
return _generate_nextStepExponential_score(
foragers_object.foragers, foragers_object.local_windows, score_name, **params
)
2 changes: 2 additions & 0 deletions collab/foraging/toolkit/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def plot_predictor(
for c in range(len(time) % ncols, ncols):
fig.delaxes(axes[c])

fig.suptitle(f"Predictor: {predictor_name}")
fig.tight_layout(pad=2)
fig.show()


def animate_predictors(
Expand Down
260 changes: 260 additions & 0 deletions docs/experimental/collab_tests/nextStep_score.ipynb

Large diffs are not rendered by default.

281 changes: 0 additions & 281 deletions docs/experimental/collab_tests/next_step_score.ipynb

This file was deleted.

Loading