API Cheatsheet

We list all the important (abstract) functions from the base classes as follows.

Algorithm

Partition

Objective

Note

The general base classes and the implemented functions are listed as follows

PyXAB.algos.Algo.Algorithm

Base class for all X-armed Bandit algorithms

class PyXAB.algos.Algo.Algorithm

Bases: abc.ABC

Abstract class for X-armed bandit algorithms.

abstract __init__()

Initialization for the algorithm

abstract get_last_point()

Every algorithm needs a function to get the last point

Returns

chosen_point – The point chosen by the algorithm

Return type

list

abstract pull(time)

Every algorithm needs a function to pull a node.

Parameters

time (int) – The time step of the online process.

Returns

chosen_point – The point chosen by the algorithm

Return type

list

abstract receive_reward(time, reward)

Every algorithm needs a function to receive the reward.

Parameters
  • time (int) – The time step of the online process.

  • reward (float) – The (Stochastic) reward of the pulled point

PyXAB.synthetic_obj.Objective.Objective

Base class for any objective

class PyXAB.synthetic_obj.Objective.Objective

Bases: abc.ABC

Abstract class for general blackbox objectives

abstract f(x)

Evaluation of the chosen point

Parameters

x (list) – one input point in the form of x = [x_1, x_2, … x_d]

Returns

y – Evaluated value of the function at the particular point

Return type

float

PyXAB.partition.Partition.Partition

Base class for any partition

class PyXAB.partition.Partition.Partition(domain, node=<class 'PyXAB.partition.Node.P_node'>)

Bases: abc.ABC

Abstract class for partition of the parameter domain

__init__(domain, node=<class 'PyXAB.partition.Node.P_node'>)

Initialization of the partition

Parameters
  • domain (list(list)) – The domain of the objective function to be optimized, should be in the form of list of lists (hypercubes), i.e., [[range1], [range2], … [range_d]], where [range_i] is a list indicating the domain’s projection on the i-th dimension, e.g., [-1, 1]

  • node – The node used in the partition, with the default choice to be P_node.

deepen()

The function to deepen the partition by one layer by making children to every node in the last layer

get_depth()

The function to get the depth of the partition

Returns

depth – The depth of the partition

Return type

int

get_layer_node_list(depth)

The function to get the all the nodes on the specified depth

Parameters

depth (int) – The depth of the layer in the partition

Returns

self.node_list – The list of nodes on the specified depth

Return type

list

get_node_list()

The function to get the list all nodes in the partition

Returns

self.node_list – The list of all nodes

Return type

list

get_root()

The function to get the root of the partition

Returns

The root node of the partition

Return type

self.root

abstract make_children(parent, newlayer=False)

The function to make children for the parent node

Parameters
  • parent – The parent node to be expanded into children nodes

  • newlayer (bool) – Boolean variable that indicates whether or not a new layer is created

PyXAB.partition.Node.P_node

Base class for any node inside a partition

class PyXAB.partition.Node.P_node(depth, index, parent, domain)

Bases: object

The most basic node class that contains everything needed to be inside a partition

__init__(depth, index, parent, domain)

Initialization of the P_node class

Parameters
  • depth (int) – The depth of the node

  • index (int) – The index of the node

  • parent – The parent node of the P_node

  • domain (list(list)) – The domain that this P_node represents

get_children()

The function to get the children of the node

get_cpoint()

The function to get the center point of the domain

get_depth()

The function to get the depth of the node

get_domain()

The function to get the domain of the node

get_index()

The function to get the index of the node

get_parent()

The function to get the parent of the node

update_children(children)

The function to update the children of the node

Parameters

children – The children nodes to be updated