cache.c File Reference

Caching of timetable fitness values. More...

#include <stdlib.h>
#include <string.h>
#include "assert.h"
#include "modsup.h"
#include "chromo.h"
#include "error.h"
#include "params.h"

Functions

int cache_init ()
 Prepare fitness cache for use.
void cache_exit ()
 Free memory used by fitness cache.
static int cache_table_changed (table *t1, table *t2)
 Compare variable chromosomes of two timetables.
static void cache_table_copy (table *dest, table *source)
 Copy variable chromosomes and fitness information from source to destination timetable.
static int cache_find (table *tab)
 Find a matching timetable in fitness cache.
void cache_table_fitness (table *tab)
 Assign a fitness to a table by first checking the cache and then calling all fitness functions.

Variables

static table ** cache_array = NULL
 Cache of timetable fitness values.
static int cache_next = 0
 Cache line that will be overwriten on the next cache miss.
static long long int cache_hit = 0
 Number of cache hits.
static long long int cache_miss = 0
 Number of cache misses.


Detailed Description

Caching of timetable fitness values.


Function Documentation

static int cache_find ( table tab  )  [static]

Find a matching timetable in fitness cache.

Parameters:
tab Timetable to search for.
Returns:
Cache line number if a matching timetable was found in cache or -1 if no match was found.

int cache_init (  ) 

Prepare fitness cache for use.

Must be run after parser_main().

Returns:
0 on success and -1 on error.

static int cache_table_changed ( table t1,
table t2 
) [static]

Compare variable chromosomes of two timetables.

Parameters:
t1 Pointer to the first timetable structure.
t2 Pointer to the second timetable structure.
Returns:
0 if timetables have identical variable chromosomes or 1 if not.

static void cache_table_copy ( table dest,
table source 
) [static]

Copy variable chromosomes and fitness information from source to destination timetable.

Parameters:
dest Pointer to the destination timetable.
source Pointer to the source timetable.

void cache_table_fitness ( table tab  ) 

Assign a fitness to a table by first checking the cache and then calling all fitness functions.

Uses table_fitness() if no matching timetable was found in fitness cache.

Parameters:
tab Pointer to the table to be fitnessd.


Variable Documentation

table** cache_array = NULL [static]

Cache of timetable fitness values.

This is an array of par_cachesize timetable structures. Only variable chromosomes and fitness values (members table_t::fitness, table_t::possible and table_t::subtotals) are valid in these structures. As far as caching logic is concerned if two timetables have identical variable chromosomes they are identical.


Generated on Tue Jul 3 13:23:35 2007 for Tablix by  doxygen 1.5.2