Utils
Pickle save
- class rostok.utils.pickle_save.Saveable(path=None, file_name='default')
Class that represents the objects that can be saved using pickle module.
CLasses inherited from that class would obtain functionality to save objects and set the path to save.
- Attributes:
path (Path): a path to directory for saving the object file_name (str): name of the file to save the object
- make_time_dependent_path()
Set path to new directory with name dependent on current time.
The new directory is created in the current path directory and path is set to the newly created directory.
- save()
Save the object as pickle file with name at the path directory using file_name.
- set_path(path: Path)
Set new path to directory for file save.
- Args:
path (Path): new path to directory
- rostok.utils.pickle_save.load_saveable(path)
The function to load a saveable object.
- Args:
path (Path): path to the corresponding pickle file
States
- class rostok.utils.states.MCTSOptimizedState(state: RobotState, reward: float, control: Any, step: int)
Class that represents the state with a calculated reward and has the step number
- Attributes:
state (RobotState): the state to calculate reward reward (float): the calculated reward of the state control (list[float]): the parameters of the optimized control step (int): MCTS step this state was obtained at
- class rostok.utils.states.OptimizedGraph(graph, reward, control)
Class that represents the graph with a calculated reward
Attributes: graph (RobotState): the graph to calculate reward reward (float): the calculated reward of the state control (list[float]): the parameters of the optimized control
- class rostok.utils.states.OptimizedState(state: RobotState, reward: float, control: Any)
Class that represents the state with a calculated reward
- Attributes:
state (RobotState): the state to calculate reward reward (float): the calculated reward of the state control (list[float]): the parameters of the optimized control
- class rostok.utils.states.RobotState(rules: RuleVocabulary, rule_list: list[str] = [])
The class that represents a mechanism within a given rule set.
This class represents a mechanism through the ordered list of rules that is used to build a graph. It requires a RuleVocabulary object that controls the building of the graph from state. The State can represent the unfinished design.
- Attributes:
rule_list (list[str]): the list of rules that determines the state
rules (RuleVocabulary): the rule set that to use for the state
- add_rule(rule: str)
Add a rule to a list of the current state.
- Args:
rule (str): the new rule to add to the state
- Raises:
Exception: the rule does not belong to the rule vocabulary assigned to the state
- create_and_add(rule: str)
Create a new state and add rule to it, return the new state.
- Args:
rule (str): the new rule to add to the state
- Raises:
Exception: the rule does not belong to the rule vocabulary assigned to the state
- make_graph()
Return a GraphGrammar object built with the rule list and rule vocabulary