AIToolbox
A library that offers tools for AI problem solving.
|
This class approximately finds the best joint action with Reusing Iterative Local Search. More...
#include <AIToolbox/Factored/Bandit/Algorithms/Utils/ReusingIterativeLocalSearch.hpp>
Public Types | |
using | Result = std::tuple< Action, double > |
using | Graph = LocalSearch::Graph |
Public Member Functions | |
ReusingIterativeLocalSearch (double resetActionProbability=0.3, double randomizeFactorProbability=0.1, unsigned trialNum=10, bool forceResetAction=true) | |
Basic constructor. More... | |
Result | operator() (const Action &A, const Graph &graph) |
This function approximately finds the best Action-value pair for the provided Graph. More... | |
double | getResetActionProbability () const |
This function returns the currently set probability for testing a random action. More... | |
void | setResetActionProbability (double resetActionProbability) |
This function sets the probability for testing a random action. More... | |
double | getRandomizeFactorProbability () const |
This function returns the currently set probability of randomizing each factor. More... | |
void | setRandomizeFactorProbability (double randomizeFactorProbability) |
This function sets the probability of randomizing each factor. More... | |
unsigned | getTrialNum () const |
This function returns the currently set number of trials to perform. More... | |
void | setTrialNum (unsigned trialNum) |
This function sets the number of trials to perform. More... | |
bool | getForceResetAction () const |
This function returns whether we always restart from a random action at each optimization. More... | |
void | setForceResetAction (bool forceResetAction) |
This function sets whether we always restart from a random action at each optimization. More... | |
This class approximately finds the best joint action with Reusing Iterative Local Search.
This class is mostly a wrapper around LocalSearch. The idea is to avoid local optima by adding noise to the solution found by LocalSearch, or alternatively restart from random points to see whether we can find a better solution.
In addition, we cache the best action found, so that we can re-use it as a starting point if needed. The idea is that if the graph to solve has changed in a relatively minor way, it is likely that the optimal solution will be close to the one found previously. Note that this caching is optional in case it is known that the graph changed substantially (or we want to solve a different graph).
using AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::Result = std::tuple<Action, double> |
AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::ReusingIterativeLocalSearch | ( | double | resetActionProbability = 0.3 , |
double | randomizeFactorProbability = 0.1 , |
||
unsigned | trialNum = 10 , |
||
bool | forceResetAction = true |
||
) |
Basic constructor.
The default parameters are provided mostly so that it's possible to initialize RILS in classes internally without knowing the explicit parameters.
It's quite likely they won't work for your problem, so remember to pass something that makes sense!
resetActionProbability | For each trial, the probability of testing a random action. |
randomizeFactorProbability | For each trial, the probability for each factor of being randomized from the current best. |
trialNum | The number of trials to perform before returning. |
forceResetAction | Whether force restarting from a random action rather than using the last returned best action. |
bool AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::getForceResetAction | ( | ) | const |
This function returns whether we always restart from a random action at each optimization.
If this is false, we always start from the lastly returned best action.
double AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::getRandomizeFactorProbability | ( | ) | const |
This function returns the currently set probability of randomizing each factor.
double AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::getResetActionProbability | ( | ) | const |
This function returns the currently set probability for testing a random action.
unsigned AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::getTrialNum | ( | ) | const |
This function returns the currently set number of trials to perform.
Result AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::operator() | ( | const Action & | A, |
const Graph & | graph | ||
) |
This function approximately finds the best Action-value pair for the provided Graph.
On first call, this function optimizes over a single randomly sampled initial action. Subsequently it will optimize using the last best action as a starting point, unless it is explicitly reset.
A | The action space of the agents. |
graph | The graph to perform RILS on. |
void AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::setForceResetAction | ( | bool | forceResetAction | ) |
This function sets whether we always restart from a random action at each optimization.
void AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::setRandomizeFactorProbability | ( | double | randomizeFactorProbability | ) |
This function sets the probability of randomizing each factor.
void AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::setResetActionProbability | ( | double | resetActionProbability | ) |
This function sets the probability for testing a random action.
void AIToolbox::Factored::Bandit::ReusingIterativeLocalSearch::setTrialNum | ( | unsigned | trialNum | ) |
This function sets the number of trials to perform.