Scippy

SCIP

Solving Constraint Integer Programs

bandit.c File Reference

Detailed Description

internal API of bandit algorithms and bandit virtual function tables

Author
Gregor Hendel

Definition in file bandit.c.

#include <assert.h>
#include <string.h>
#include "scip/bandit.h"
#include "scip/pub_bandit.h"
#include "scip/struct_bandit.h"
#include "struct_set.h"
#include "scip/set.h"

Go to the source code of this file.

Functions

SCIP_RETCODE SCIPbanditCreate (SCIP_BANDIT **bandit, SCIP_BANDITVTABLE *banditvtable, BMS_BLKMEM *blkmem, BMS_BUFMEM *bufmem, SCIP_Real *priorities, int nactions, unsigned int initseed, SCIP_BANDITDATA *banditdata)
 
SCIP_RETCODE SCIPbanditFree (BMS_BLKMEM *blkmem, SCIP_BANDIT **bandit)
 
SCIP_RETCODE SCIPbanditReset (BMS_BUFMEM *bufmem, SCIP_BANDIT *bandit, SCIP_Real *priorities, unsigned int seed)
 
SCIP_RETCODE SCIPbanditSelect (SCIP_BANDIT *bandit, int *action)
 
SCIP_RETCODE SCIPbanditUpdate (SCIP_BANDIT *bandit, int action, SCIP_Real score)
 
SCIP_BANDITDATASCIPbanditGetData (SCIP_BANDIT *bandit)
 
void SCIPbanditSetData (SCIP_BANDIT *bandit, SCIP_BANDITDATA *banditdata)
 
static SCIP_RETCODE doBanditvtableCreate (SCIP_BANDITVTABLE **banditvtable, const char *name, SCIP_DECL_BANDITFREE((*banditfree)), SCIP_DECL_BANDITSELECT((*banditselect)), SCIP_DECL_BANDITUPDATE((*banditupdate)), SCIP_DECL_BANDITRESET((*banditreset)))
 
SCIP_RETCODE SCIPbanditvtableCreate (SCIP_BANDITVTABLE **banditvtable, const char *name, SCIP_DECL_BANDITFREE((*banditfree)), SCIP_DECL_BANDITSELECT((*banditselect)), SCIP_DECL_BANDITUPDATE((*banditupdate)), SCIP_DECL_BANDITRESET((*banditreset)))
 
void SCIPbanditvtableFree (SCIP_BANDITVTABLE **banditvtable)
 
const char * SCIPbanditvtableGetName (SCIP_BANDITVTABLE *banditvtable)
 
SCIP_RANDNUMGENSCIPbanditGetRandnumgen (SCIP_BANDIT *bandit)
 
int SCIPbanditGetNActions (SCIP_BANDIT *bandit)
 

Function Documentation

◆ SCIPbanditCreate()

SCIP_RETCODE SCIPbanditCreate ( SCIP_BANDIT **  bandit,
SCIP_BANDITVTABLE banditvtable,
BMS_BLKMEM blkmem,
BMS_BUFMEM bufmem,
SCIP_Real priorities,
int  nactions,
unsigned int  initseed,
SCIP_BANDITDATA banditdata 
)

creates and resets bandit algorithm

Parameters
banditpointer to bandit algorithm data structure
banditvtablevirtual table for this bandit algorithm
blkmemblock memory for parameter settings
bufmembuffer memory
prioritiesnonnegative priorities for each action, or NULL if not needed
nactionsthe positive number of actions for this bandit
initseedinitial seed for random number generation
banditdataalgorithm specific bandit data

Definition at line 32 of file bandit.c.

References BMSallocBlockMemory, SCIP_Bandit::data, SCIP_Bandit::nactions, NULL, SCIP_Bandit::rng, SCIP_ALLOC, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPbanditReset(), SCIPerrorMessage, SCIPrandomCreate(), and SCIP_Bandit::vtable.

Referenced by SCIPbanditCreateEpsgreedy(), SCIPbanditCreateExp3(), and SCIPbanditCreateUcb().

◆ SCIPbanditFree()

SCIP_RETCODE SCIPbanditFree ( BMS_BLKMEM blkmem,
SCIP_BANDIT **  bandit 
)

calls destructor and frees memory of bandit algorithm

Parameters
blkmemblock memory
banditpointer to bandit algorithm data structure

Definition at line 70 of file bandit.c.

References BMSfreeBlockMemory, NULL, SCIP_Bandit::rng, SCIP_CALL, SCIP_OKAY, SCIPrandomFree(), and SCIP_Bandit::vtable.

Referenced by SCIPfreeBandit().

◆ SCIPbanditReset()

SCIP_RETCODE SCIPbanditReset ( BMS_BUFMEM bufmem,
SCIP_BANDIT bandit,
SCIP_Real priorities,
unsigned int  seed 
)

reset the bandit algorithm

Parameters
bufmembuffer memory
banditpointer to bandit algorithm data structure
prioritiesnonnegative priorities for each action, or NULL if not needed
seedinitial seed for random number generation

Definition at line 99 of file bandit.c.

References NULL, SCIP_Bandit::rng, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPbanditGetNActions(), SCIPerrorMessage, SCIPrandomSetSeed(), and SCIP_Bandit::vtable.

Referenced by SCIPbanditCreate(), and SCIPresetBandit().

◆ SCIPbanditGetData()

◆ SCIPbanditSetData()

void SCIPbanditSetData ( SCIP_BANDIT bandit,
SCIP_BANDITDATA banditdata 
)

set the data of this bandit algorithm

Parameters
banditbandit algorithm data structure
banditdatabandit algorihm specific data, or NULL

Definition at line 190 of file bandit.c.

References SCIP_Bandit::data, and NULL.

Referenced by SCIP_DECL_BANDITFREE().

◆ doBanditvtableCreate()

static SCIP_RETCODE doBanditvtableCreate ( SCIP_BANDITVTABLE **  banditvtable,
const char *  name,
SCIP_DECL_BANDITFREE((*banditfree))  ,
SCIP_DECL_BANDITSELECT((*banditselect))  ,
SCIP_DECL_BANDITUPDATE((*banditupdate))  ,
SCIP_DECL_BANDITRESET((*banditreset))   
)
static

internal method to create a bandit VTable

Parameters
banditvtablepointer to virtual table for bandit algorithm
namea name for the algorithm represented by this vtable

Definition at line 202 of file bandit.c.

References BMSallocMemory, BMSclearMemory, BMSduplicateMemoryArray, NULL, SCIP_ALLOC, and SCIP_OKAY.

Referenced by SCIPbanditvtableCreate().

◆ SCIPbanditvtableCreate()

SCIP_RETCODE SCIPbanditvtableCreate ( SCIP_BANDITVTABLE **  banditvtable,
const char *  name,
SCIP_DECL_BANDITFREE((*banditfree))  ,
SCIP_DECL_BANDITSELECT((*banditselect))  ,
SCIP_DECL_BANDITUPDATE((*banditupdate))  ,
SCIP_DECL_BANDITRESET((*banditreset))   
)

create a bandit VTable for bandit algorithm callback functions

Parameters
banditvtablepointer to virtual table for bandit algorithm
namea name for the algorithm represented by this vtable

Definition at line 235 of file bandit.c.

References doBanditvtableCreate(), NULL, SCIP_CALL_FINALLY, SCIP_OKAY, and SCIPbanditvtableFree().

Referenced by SCIPincludeBanditvtable().

◆ SCIPbanditvtableFree()

void SCIPbanditvtableFree ( SCIP_BANDITVTABLE **  banditvtable)

free a bandit virtual table for bandit algorithm callback functions

Parameters
banditvtablepointer to virtual table for bandit algorithm

Definition at line 259 of file bandit.c.

References BMSfreeMemory, BMSfreeMemoryArrayNull, and NULL.

Referenced by SCIPbanditvtableCreate(), and SCIPsetFree().