timor.task.CostFunctions

Attributes

abbreviations

abbreviations_inverse

Classes

ComposedCost

A cost function composed of different atomic cost functions

CostFunctionBase

A base class for cost functions that are evaluated on task solutions.

CycleTime

Increases with trajectory length needed to solve a task

Effort

Increases with the torques used by a solution

GoalsFulfilled

Cost of alpha for every goal fulfilled in the task. (negative weight --> reward)

GoalsFulfilledFraction

Cost proportional to the fraction of fulfilled goals.

LinkSideMechanicalEnergy

Calculate the energy used in the link side movement EXCLUDING joint friction and rotor inertia.

MechanicalEnergy

Calculate the energy provided by the motors to move the robot along the solution trajectory.

NumJoints

Punishes a higher number of actuated joints

QDist

Increases with the joint space distance traversed by the solution

RobotMass

Punishes higher weight of the robot

Module Contents

class timor.task.CostFunctions.ComposedCost(*args, weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.ComposedCost

A cost function composed of different atomic cost functions

A composed cost is a container with multiple cost functions, providing a unified interface.

Parameters:

weight (float)

__add__(other)

The sum of two costs

__eq__(other)

Check if two composed cost functions are the same, i.e., have the same descriptor.

Parameters:

other (CostFunctionBase)

Return type:

bool

__mul__(other)

Multiply all internal cost functions by the given number.

__neg__()

Negate all internal cost functions.

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Divide all internal cost functions by the given number.

_evaluate(solution)

The evaluation of the composed cost function is the sum of all internal cost functions

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

_internal = []
default_weight = 1.0
descriptor()

Creates a string describing this cost function. Uses alphanumeric sorting to ensure deterministic name.

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.CostFunctionBase(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.CostFunctionBase

A base class for cost functions that are evaluated on task solutions.

By default, cost functions return positive values - if they describe something positive (e.g. number of goals fulfilled), the weight must be chosen negative.

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

abstractmethod _evaluate(solution)

Interface to define class-level evaluate functions

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.CycleTime(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.CycleTime

Increases with trajectory length needed to solve a task

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The total time needed by the solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.Effort(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.Effort

Increases with the torques used by a solution

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The integral of effort over time in the solution

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.GoalsFulfilled(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.GoalsFulfilled

Cost of alpha for every goal fulfilled in the task. (negative weight –> reward)

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The number of goals fulfilled

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.GoalsFulfilledFraction(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.GoalsFulfilledFraction

Cost proportional to the fraction of fulfilled goals.

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The fraction of goals fulfilled

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.LinkSideMechanicalEnergy(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.LinkSideMechanicalEnergy

Calculate the energy used in the link side movement EXCLUDING joint friction and rotor inertia.

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The integral of mechanical power (excl. joint friction and inertia) over the solution times.

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.MechanicalEnergy(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.MechanicalEnergy

Calculate the energy provided by the motors to move the robot along the solution trajectory.

Includes the energy to overcome joint friction, rotor inertia and all link inertias.

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The integral of mechanical power over time in the solution.

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.NumJoints(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.NumJoints

Punishes a higher number of actuated joints

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The number of actuated joints in the solution robot

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.QDist(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.QDist

Increases with the joint space distance traversed by the solution

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The integral over time for all joint parameters (mixes up radian and meters!)

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
class timor.task.CostFunctions.RobotMass(weight=default_weight)
Inheritance diagram of timor.task.CostFunctions.RobotMass

Punishes higher weight of the robot

create a weighted cost

The default weight should be chosen in a way that higher cost means worse outcome. In case of rewards (e.g. cost proportional to goals achieved), the weight should default to a negative value.

Parameters:

weight (float) – Can be any number, positive or negative.

__add__(other)

The sum of two costs

__eq__(other)

Check if cost functions are the same.

Return type:

bool

__mul__(other)

Change the cost function’s weight by multiplying it by a float

__neg__()

Negate the cost function’s weight (e.g. for rewards)

__slots__ = ()
__str__()

Turn cost function into string representation.

Return type:

str

__sub__(other)

The difference of two costs

__truediv__(other)

Change the cost function’s weight by dividing it by a float

_evaluate(solution)

The total mass of the solution robot

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

default_weight = 1.0
descriptor(scale=1.0)

Creates a string describing this cost function which can be used for serialization.

Parameters:

scale (float)

Return type:

str

classmethod empty()

Return an empty cost function

Return type:

ComposedCost

evaluate(solution)

Calculates the cost of the solution for its internally stored task

Parameters:

solution (timor.task.Solution.SolutionBase)

Return type:

float

static from_descriptor(descriptor)

Build the cost from a string:

Takes a description string for a cost function and returns the corresponding instance

Parameters:

descriptor (str) – Abbreviation for the cost function. Format <name> or <name_weight>

Returns:

instance of the cost function

Return type:

CostFunctionBase

weight = 1.0
timor.task.CostFunctions.abbreviations
timor.task.CostFunctions.abbreviations_inverse