pbvi_agent
PBVI_Agent
Bases: Agent
A generic Point-Based Value Iteration based agent. It relies on Model-Based reinforcement learning as described in: Pineau J. et al, Point-based value iteration: An anytime algorithm for POMDPs The training consist in two steps:
-
Expand: Where belief points are explored based on the some strategy (to be defined by subclasses).
-
Backup: Using the generated belief points, the value function is updated.
The belief points are probability distributions over the state space and are therefore vectors of |S| elements.
Actions are chosen based on a value function. A value function is a set of alpha vectors of dimentionality |S|. Each alpha vector is associated to a single action but multiple alpha vectors can be associated to the same action. To choose an action at a given belief point, a dot product is taken between each alpha vector and the belief point and the action associated with the highest result is chosen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
environment
|
Environment
|
The olfactory environment to train the agent with. |
required |
thresholds
|
float or list[float] or dict[str, float] or dict[str, list[float]]
|
The olfactory thresholds. If an odor cue above this threshold is detected, the agent detects it, else it does not. If a list of thresholds is provided, he agent should be able to detect |thresholds|+1 levels of odor. A dictionary of (list of) thresholds can also be provided when the environment is layered. In such case, the number of layers provided must match the environment's layers and their labels must match. The thresholds provided will be converted to an array where the levels start with -inf and end with +inf. |
3e-6
|
space_aware
|
bool
|
Whether the agent is aware of it's own position in space. This is to be used in scenarios where, for example, the agent is an enclosed container and the source is the variable. Note: The observation array will have a different shape when returned to the update_state function! |
False
|
spacial_subdivisions
|
ndarray
|
How many spacial compartments the agent has to internally represent the space it lives in. By default, it will be as many as there are grid points in the environment. |
None
|
actions
|
dict or ndarray
|
The set of action available to the agent. It should match the type of environment (ie: if the environment has layers, it should contain a layer component to the action vector, and similarly for a third dimension). Else, a dict of strings and action vectors where the strings represent the action labels. If none is provided, by default, all unit movement vectors are included and shuch for all layers (if the environment has layers.) |
None
|
name
|
str
|
A custom name to give the agent. If not provided is will be a combination of the class-name and the threshold. |
None
|
seed
|
int
|
For reproducible randomness. |
12131415
|
model
|
Model
|
A POMDP model to use to represent the olfactory environment. If not provided, the environment_converter parameter will be used. |
None
|
environment_converter
|
Callable
|
A function to convert the olfactory environment instance to a POMDP Model instance. By default, we use an exact convertion that keeps the shape of the environment to make the amount of states of the POMDP Model. This parameter will be ignored if the model parameter is provided. |
exact_converter
|
converter_parameters
|
dict
|
A set of additional parameters to be passed down to the environment converter. |
{}
|
Attributes:
Name | Type | Description |
---|---|---|
environment |
Environment
|
|
thresholds |
ndarray
|
An array of the thresholds of detection, starting with -inf and ending with +inf. In the case of a 2D array of thresholds, the rows of thresholds apply to the different layers of the environment. |
space_aware |
bool
|
|
spacial_subdivisions |
ndarray
|
|
name |
str
|
|
action_set |
ndarray
|
The actions allowed of the agent. Formulated as movement vectors as [(layer,) (dz,) dy, dx]. |
action_labels |
list[str]
|
The labels associated to the action vectors present in the action set. |
model |
Model
|
The environment converted to a POMDP model using the "from_environment" constructor of the Model class. |
saved_at |
str
|
The place on disk where the agent has been saved (None if not saved yet). |
on_gpu |
bool
|
Whether the agent has been sent to the gpu or not. |
class_name |
str
|
The name of the class of the agent. |
seed |
int
|
The seed used for the random operations (to allow for reproducability). |
rnd_state |
RandomState
|
The random state variable used to generate random values. |
cpu_version |
Agent
|
An instance of the agent on the CPU. If it already is, it returns itself. |
gpu_version |
Agent
|
An instance of the agent on the CPU. If it already is, it returns itself. |
trained_at |
str
|
A string timestamp of when the agent has been trained (None if not trained yet). |
value_function |
ValueFunction
|
The value function used for the agent to make decisions. |
belief |
BeliefSet
|
Used only during simulations. Part of the Agent's status. Where the agent believes he is over the state space. It is a list of n belief points based on how many simulations are running at once. |
action_played |
list[int]
|
Used only during simulations. Part of the Agent's status. Records what action was last played by the agent. A list of n actions played based on how many simulations are running at once. |
Source code in olfactory_navigation/agents/pbvi_agent.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
|
backup(belief_set, value_function, gamma=0.99, append=False, belief_dominance_prune=True)
This function has purpose to update the set of alpha vectors. It does so in 3 steps: 1. It creates projections from each alpha vector for each possible action and each possible observation 2. It collapses this set of generated alpha vectors by taking the weighted sum of the alpha vectors weighted by the observation probability and this for each action and for each belief. 3. Then it further collapses the set to take the best alpha vector and action per belief In the end we have a set of alpha vectors as large as the amount of beliefs.
The alpha vectors are also pruned to avoid duplicates and remove dominated ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
belief_set
|
BeliefSet
|
The belief set to use to generate the new alpha vectors with. |
required |
value_function
|
ValueFunction
|
The alpha vectors to generate the new set from. |
required |
gamma
|
float
|
The discount factor to value immediate rewards more than long term rewards. The learning rate is 1/gamma. |
0.99
|
append
|
bool
|
Whether to append the new alpha vectors generated to the old alpha vectors before pruning. |
False
|
belief_dominance_prune
|
bool
|
Whether, before returning the new value function, checks what alpha vectors have a supperior value, if so it adds it. |
True
|
Returns:
Name | Type | Description |
---|---|---|
new_alpha_set |
ValueFunction
|
A list of updated alpha vectors. |
Source code in olfactory_navigation/agents/pbvi_agent.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
choose_action()
Function to let the agent or set of agents choose an action based on their current belief.
Returns:
Name | Type | Description |
---|---|---|
movement_vector |
ndarray
|
A single or a list of actions chosen by the agent(s) based on their belief. |
Source code in olfactory_navigation/agents/pbvi_agent.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
|
compute_change(value_function, new_value_function, belief_set)
Function to compute whether the change between two value functions can be considered as having converged based on the eps parameter of the Solver. It check for each belief, the maximum value and take the max change between believe's value functions. If this max change is lower than eps * (gamma / (1 - gamma)).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value_function
|
ValueFunction
|
The first value function to compare. |
required |
new_value_function
|
ValueFunction
|
The second value function to compare. |
required |
belief_set
|
BeliefSet
|
The set of believes to check the values on to compute the max change on. |
required |
Returns:
Name | Type | Description |
---|---|---|
max_change |
float
|
The maximum change between value functions at belief points. |
Source code in olfactory_navigation/agents/pbvi_agent.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 |
|
expand(belief_set, value_function, max_generation, **kwargs)
Abstract function! This function should be implemented in subclasses. The expand function consists in the exploration of the belief set. It takes as input a belief set and generates at most 'max_generation' beliefs from it.
The current value function is also passed as an argument as it is used in some PBVI techniques to guide the belief exploration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
belief_set
|
BeliefSet
|
The belief or set of beliefs to be used as a starting point for the exploration. |
required |
value_function
|
ValueFunction
|
The current value function. To be used to guide the exploration process. |
required |
max_generation
|
int
|
How many beliefs to be generated at most. |
required |
kwargs
|
Special parameters for the particular flavors of the PBVI Agent. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
new_belief_set |
BeliefSet
|
A new (or expanded) set of beliefs. |
Source code in olfactory_navigation/agents/pbvi_agent.py
909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
|
generate_beliefs_from_trajectory(history, trajectory_i=0, initial_belief=None)
Function to generate a sequence of belief points from the trajectory from SimulationHistory instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
history
|
SimulationHistory
|
The simulation history from which the agent's trajectory is extracted. |
required |
trajectory_i
|
int
|
The id of the trajectory from which to build the belief sequence. |
0
|
initial_belief
|
Belief
|
The initial belief point from which to start the sequence. |
None
|
Returns:
Name | Type | Description |
---|---|---|
belief_sequence |
BeliefSet
|
The sequence of beliefs the agent going through in the the trajectory of the simulation. |
Source code in olfactory_navigation/agents/pbvi_agent.py
1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
|
initialize_state(n=1, belief=None)
To use an agent within a simulation, the agent's state needs to be initialized. The initialization consists of setting the agent's initial belief. Multiple agents can be used at once for simulations, for this reason, the belief parameter is a BeliefSet by default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
How many agents are to be used during the simulation. |
1
|
belief
|
BeliefSet
|
An optional set of beliefs to initialize the simulations with. |
None
|
Source code in olfactory_navigation/agents/pbvi_agent.py
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
kill(simulations_to_kill)
Function to kill any simulations that have not reached the source but can't continue further
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulations_to_kill
|
ndarray
|
A boolean array of the simulations to kill. |
required |
Source code in olfactory_navigation/agents/pbvi_agent.py
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 |
|
load(folder)
classmethod
Function to load a PBVI agent from a given folder it has been saved to. It will load the environment the agent has been trained on along with it.
If it is a subclass of the PBVI_Agent, an instance of that specific subclass will be returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder
|
str
|
The agent folder. |
required |
Returns:
Name | Type | Description |
---|---|---|
instance |
PBVI_Agent
|
The loaded instance of the PBVI Agent. |
Source code in olfactory_navigation/agents/pbvi_agent.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
modify_environment(new_environment)
Function to modify the environment of the agent. If the agent is already trained, the trained element should also be adapted to fit this new environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_environment
|
Environment
|
A modified environment. |
required |
Returns:
Name | Type | Description |
---|---|---|
modified_agent |
PBVI_Agent
|
A new pbvi agent with a modified environment |
Source code in olfactory_navigation/agents/pbvi_agent.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
|
save(folder=None, force=False, save_environment=False)
The save function for PBVI Agents consists in recording the value function after the training. It saves the agent in a folder with the name of the agent (class name + training timestamp). In this folder, there will be the metadata of the agent (all the attributes) in a json format and the value function.
Optionally, the environment can be saved too to be able to load it alongside the agent for future reuse. If the agent has already been saved, the saving will not happen unless the force parameter is toggled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder
|
str
|
The folder under which to save the agent (a subfolder will be created under this folder).
The agent will therefore be saved at |
None
|
force
|
bool
|
Whether to overwrite an already saved agent with the same name at the same path. |
False
|
save_environment
|
bool
|
Whether to save the environment data along with the agent. |
False
|
Source code in olfactory_navigation/agents/pbvi_agent.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
|
to_cpu()
Function to send the numpy arrays of the agent to the cpu. It returns a new instance of the Agent class with the arrays on the cpu.
Returns:
Name | Type | Description |
---|---|---|
cpu_agent |
Agent
|
A new environment instance where the arrays are on the cpu memory. |
Source code in olfactory_navigation/agents/pbvi_agent.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
to_gpu()
Function to send the numpy arrays of the agent to the gpu. It returns a new instance of the Agent class with the arrays on the gpu.
Returns:
Name | Type | Description |
---|---|---|
gpu_agent |
Agent
|
A copy of the agent with the arrays on the GPU. |
Source code in olfactory_navigation/agents/pbvi_agent.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
train(expansions, full_backup=True, update_passes=1, max_belief_growth=10, initial_belief=None, initial_value_function=None, prune_level=1, prune_interval=10, limit_value_function_size=-1, gamma=0.99, eps=1e-06, use_gpu=False, history_tracking_level=1, overwrite_training=False, print_progress=True, print_stats=True, **expand_arguments)
Main loop of the Point-Based Value Iteration algorithm. It consists in 2 steps, Backup and Expand. 1. Expand: Expands the belief set base with a expansion strategy given by the parameter expand_function 2. Backup: Updates the alpha vectors based on the current belief set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expansions
|
int
|
How many times the algorithm has to expand the belief set. (the size will be doubled every time, eg: for 5, the belief set will be of size 32) |
required |
full_backup
|
bool
|
Whether to force the backup function has to be run on the full set beliefs uncovered since the beginning or only on the new points. |
True
|
update_passes
|
int
|
How many times the backup function has to be run every time the belief set is expanded. |
1
|
max_belief_growth
|
int
|
How many beliefs can be added at every expansion step to the belief set. |
10
|
initial_belief
|
BeliefSet or Belief
|
An initial list of beliefs to start with. |
None
|
initial_value_function
|
ValueFunction
|
An initial value function to start the solving process with. |
None
|
prune_level
|
int
|
Parameter to prune the value function further before the expand function. |
1
|
prune_interval
|
int
|
How often to prune the value function. It is counted in number of backup iterations. |
10
|
limit_value_function_size
|
int
|
When the value function size crosses this threshold, a random selection of 'max_belief_growth' alpha vectors will be removed from the value function If set to -1, the value function can grow without bounds. |
-1
|
use_gpu
|
bool
|
Whether to use the GPU with cupy array to accelerate solving. |
False
|
gamma
|
float
|
The discount factor to value immediate rewards more than long term rewards. The learning rate is 1/gamma. |
0.99
|
eps
|
float
|
The smallest allowed changed for the value function. Bellow the amound of change, the value function is considered converged and the value iteration process will end early. |
1e-6
|
history_tracking_level
|
int
|
How thorough the tracking of the solving process should be. (0: Nothing; 1: Times and sizes of belief sets and value function; 2: The actual value functions and beliefs sets) |
1
|
overwrite_training
|
bool
|
Whether to force the overwriting of the training if a value function already exists for this agent. |
False
|
print_progress
|
bool
|
Whether or not to print out the progress of the value iteration process. |
True
|
print_stats
|
bool
|
Whether or not to print out statistics at the end of the training run. |
True
|
expand_arguments
|
kwargs
|
An arbitrary amount of parameters that will be passed on to the expand function. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
solver_history |
SolverHistory
|
The history of the solving process with some plotting options. |
Source code in olfactory_navigation/agents/pbvi_agent.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 |
|
update_state(action, observation, source_reached)
Function to update the internal state(s) of the agent(s) based on the previous action(s) taken and the observation(s) received.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
ndarray
|
A 2D array of n movement vectors. If the environment is layered, the 1st component should be the layer. |
required |
observation
|
ndarray
|
The observation(s) the agent(s) made. |
required |
source_reached
|
ndarray
|
A boolean array of whether the agent(s) have reached the source or not. |
required |
Returns:
Name | Type | Description |
---|---|---|
update_successfull |
(ndarray, optional)
|
If nothing is returned, it means all the agent's state updates have been successfull. Else, a boolean np.ndarray of size n can be returned confirming for each agent whether the update has been successful or not. |
Source code in olfactory_navigation/agents/pbvi_agent.py
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 |
|
TrainingHistory
Class to represent the history of a solver for a POMDP solver. It has mainly the purpose to have visualizations for the solution, belief set and the whole solving history. The visualizations available are: - Belief set plot - Solution plot - Video of value function and belief set evolution over training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tracking_level
|
int
|
The tracking level of the solver. |
required |
model
|
Model
|
The model the solver has solved. |
required |
gamma
|
float
|
The gamma parameter used by the solver (learning rate). |
required |
eps
|
float
|
The epsilon parameter used by the solver (covergence bound). |
required |
expand_append
|
bool
|
Whether the expand function appends new belief points to the belief set of reloads it all. |
required |
initial_value_function
|
ValueFunction
|
The initial value function the solver will use to start the solving process. |
required |
initial_belief_set
|
BeliefSet
|
The initial belief set the solver will use to start the solving process. |
required |
Attributes:
Name | Type | Description |
---|---|---|
tracking_level |
int
|
|
model |
Model
|
|
gamma |
float
|
|
eps |
float
|
|
expand_append |
bool
|
|
run_ts |
datetime
|
The time at which the SolverHistory object was instantiated which is assumed to be the start of the solving run. |
expansion_times |
list[float]
|
A list of recorded times of the expand function. |
backup_times |
list[float]
|
A list of recorded times of the backup function. |
alpha_vector_counts |
list[int]
|
A list of recorded alpha vector count making up the value function over the solving process. |
beliefs_counts |
list[int]
|
A list of recorded belief count making up the belief set over the solving process. |
value_function_changes |
list[float]
|
A list of recorded value function changes (the maximum changed value between 2 value functions). |
value_functions |
list[ValueFunction]
|
A list of recorded value functions. |
belief_sets |
list[BeliefSet]
|
A list of recorded belief sets. |
solution |
ValueFunction
|
|
explored_beliefs |
BeliefSet
|
|
Source code in olfactory_navigation/agents/pbvi_agent.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
explored_beliefs
property
The final set of beliefs explored during the solving.
solution
property
The last value function of the solving process.
summary
property
A summary as a string of the information recorded.
add_backup_step(backup_time, value_function_change, value_function)
Function to add a backup step in the simulation history by recording the value function the backup function generated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backup_time
|
float
|
The time it took to run a step of backup of the value function. (Also known as the value function update.) |
required |
value_function_change
|
float
|
The change between the value function of this iteration and of the previous iteration. |
required |
value_function
|
ValueFunction
|
The value function resulting after a step of the solving process. |
required |
Source code in olfactory_navigation/agents/pbvi_agent.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
add_expand_step(expansion_time, belief_set)
Function to add an expansion step in the simulation history by the explored belief set the expand function generated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expansion_time
|
float
|
The time it took to run a step of expansion of the belief set. (Also known as the exploration step.) |
required |
belief_set
|
BeliefSet
|
The belief set used for the Update step of the solving process. |
required |
Source code in olfactory_navigation/agents/pbvi_agent.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
add_prune_step(prune_time, alpha_vectors_pruned)
Function to add a prune step in the simulation history by recording the amount of alpha vectors that were pruned by the pruning function and how long it took.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prune_time
|
float
|
The time it took to run the pruning step. |
required |
alpha_vectors_pruned
|
int
|
How many alpha vectors were pruned. |
required |
Source code in olfactory_navigation/agents/pbvi_agent.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|