data.h File Reference

#include "chromo.h"

This graph shows which files directly or indirectly include this file:


Data Structures

struct  miscinfo_t
 Structure holding miscellaneous information about the timetable. More...
struct  tuplelist_t
 A list of tuple IDs. More...
struct  outputext_t
 Output extension structure. More...
struct  ext_t
 Extension structure. More...
struct  slist_t
 Slist structure. More...

Defines

#define res_get_conflict(restype, resid1, resid2)   ((restype)->conflicts[resid1][resid2])
 Get conflict between two resources.

Typedefs

typedef slist_t slist
typedef outputext_t outputext
typedef ext_t ext
typedef miscinfo_t miscinfo
typedef tuplelist_t tuplelist

Functions

populationpopulation_init (population *pop, int size)
 Initializes population structure.
void population_rand (population *pop)
 Randomize the entire population.
void population_hint (population *pop, int hintpart)
 Hint a part of the population.
int data_init ()
 Prepare data structures for use.
void data_exit ()
 Free all memory allocated by restype_new(), res_new(), domain_new() and tuple_new().
resourcetyperestype_new (int var, char *type)
 Define a new resource type.
resourcetyperestype_find (char *type)
 Find a resource type by name.
int restype_findid (char *type)
 Find a resource type (either variable or constant) by name and return a resource type ID.
resourceres_new (resourcetype *restype, char *name)
 Add a new resource to a resource type.
resourceres_new_matrix (resourcetype *restype, int width, int height)
 Adds a matrix of resources to a resource type.
int res_get_matrix (resourcetype *restype, int *width, int *height)
 Finds the dimensions of a matrix of resources.
int res_findid (resourcetype *restype, char *name)
 Find a resource by name and return its resource ID.
resourceres_find (resourcetype *restype, char *name)
 Find a resource by name.
void res_set_conflict (resource *res1, resource *res2)
 Set conflict between resource res1 and resource res2.
tupleinfotuple_new (char *name)
 Add a new tuple.
void tuple_set (tupleinfo *tuple, resource *res)
 Set a resource in a tuple.
int tuple_compare (int tupleid1, int tupleid2)
 Compare two events.
int domain_rand (domain *dom)
 Returns a random value from a domain.
void domain_and (domain *dom, int *val, int valnum)
 Removes some values from a domain.
int domain_check (domain *dom, int val)
 Checks if a value is present in a domain.
extext_new (ext **ex, int contype, int vartype)
 Allocate a new extension struct in a linked list.
slistslist_new (slist **list, int vartype)
 Allocate a new slist struct in a linked list.
void ext_update (ext *ex, table *tab)
 Update extension with new data from a timetable.
void slist_update (slist *list, table *tab)
 Update slist with new data from a timetable.
outputextoutputext_new (char *contype, char *vartype)
 Allocate a new output extension struct.
int outputext_update (outputext *ex, table *tab)
 Update output extension with new data from a timetable.
void outputext_free (outputext *dest)
 Free an output extension struct.

Variables

miscinfo dat_info
 Miscellaneous information about the timetable.
int dat_typenum
 Number of all defined resource types.
resourcetypedat_restype
 Array of dat_typenum resource types.
int dat_tuplenum
 Number of all defined tuples (events).
tupleinfodat_tuplemap
 Array of dat_tuplenum tuples.

Detailed Description


Define Documentation

#define res_get_conflict ( restype,
resid1,
resid2   )     ((restype)->conflicts[resid1][resid2])

Get conflict between two resources.

Parameters:
restype Pointer to the resource type structure.
resid1 Integer resource ID of the first resource.
resid2 Integer resource ID of the second resource.
Returns:
Integer 1 if first resource conflicts with the second resource or integer 0 if not.


Function Documentation

int data_init (  ) 

Prepare data structures for use.

Returns:
0 on success and -1 on error.

void domain_and ( domain dom,
int *  val,
int  valnum 
)

Removes some values from a domain.

This function removes all values from dom domain that are not in the val list.

Parameters:
dom Pointer to the domain struct
val Array of values
valnum Number of values in the array

int domain_check ( domain dom,
int  val 
)

Checks if a value is present in a domain.

Parameters:
dom Pointer to the domain struct.
val Value to be checked for.
Returns:
1 if the value is present in a domain or 0 if the value is not present.

int domain_rand ( domain dom  ) 

Returns a random value from a domain.

Parameters:
dom Pointer to the domain struct.
Returns:
Random value from the domain.

ext* ext_new ( ext **  ex,
int  contype,
int  vartype 
)

Allocate a new extension struct in a linked list.

Linked list is first searched for an identical extension struct. If such a structure is found, only a pointer to it is returned and the linked is is not changed. If no such structure exists, a new structure is allocated and inserted at the beginning of the linked list.

Parameters:
ex Pointer to the linked list.
contype Constant resource type id.
vartype Variable resource type id.
Returns:
Pointer to the new extension struct or NULL on error.

void ext_update ( ext ex,
table tab 
)

Update extension with new data from a timetable.

Parameters:
ex Pointer to the extension structure to update.
tab Pointer to the table with the new data.

void outputext_free ( outputext dest  ) 

Free an output extension struct.

Parameters:
dest Pointer to the output extenstion struct to free.

outputext* outputext_new ( char *  contype,
char *  vartype 
)

Allocate a new output extension struct.

Parameters:
contype Constant resource type.
vartype Variable resource type.
Returns:
Pointer to the new output extension struct or NULL on error.

int outputext_update ( outputext ex,
table tab 
)

Update output extension with new data from a timetable.

Parameters:
ex Pointer to the output extension structure to update.
tab Pointer to the table with the new data.
Returns:
0 on success and -1 on error.

void population_hint ( population pop,
int  hintpart 
)

Hint a part of the population.

If dat_tuplemap contains information that can be used to initialize variable chromosomes in the population (i.e. the user has loaded an XML file that already contains a partial or a full solution), then this function initializes some variable chromosomes.

If dat_tuplemap doesn't contain this information this function does nothing.

If the information in dat_tuplemap conflicts with a domain of a tuple then the dat_tuplemap information is ignored for that tuple and an error is reported.

Parameters:
pop Pointer to the population to be hinted.
hintpart Percent of the population that will be hinted.

population* population_init ( population pop,
int  size 
)

Initializes population structure.

All resources, resource types and tuples (events) must be defined before calling this function.

If pop is NULL, a new structure with population size size is allocated using the number of tuples and resource types. If pop is not NULL then only proper links to resources, etc. are made.

Checks are also performed to see if population pop is compatible with the number of defined resource types, etc. size parameter is not used in this case.

Parameters:
pop Pointer to the population structure to be initialized.
size Size of the population.
Returns:
Pointer to the initialized structure on success and NULL on error.

void population_rand ( population pop  ) 

Randomize the entire population.

All variable chromosomes in the population are filled with random values (domains of individual tuples, as specified in dat_tuplemap are respected)

Parameters:
pop Pointer to the population to be randomized.

resource* res_find ( resourcetype restype,
char *  name 
)

Find a resource by name.

Parameters:
restype Pointer to the resource type structure in which to search for the resource.
name Name of the resource type to find.
Returns:
Pointer to the resource structure or NULL if this resource was not found.

int res_findid ( resourcetype restype,
char *  name 
)

Find a resource by name and return its resource ID.

Parameters:
restype Pointer to the resource type structure in which to search for the resource.
name Name of the resource type to find.
Returns:
Resource ID or INT_MIN if this resource was not found.

int res_get_matrix ( resourcetype restype,
int *  width,
int *  height 
)

Finds the dimensions of a matrix of resources.

This function finds the width and height of a matrix of resources that was defined by the res_new_matrix() function. There must be no other resources defined in the specified resource type.

Parameters:
restype Pointer to the resource type structure.
width Width of the matrix.
height Height of the matrix.
Returns:
0 on success (width and height are set to correct values) and -1 on error (this resource type does not contain a matrix of resources - width and height are not touched.

resource* res_new ( resourcetype restype,
char *  name 
)

Add a new resource to a resource type.

After the first resource was added, any calls to restype_new() have unspecified effects.

Parameters:
restype Pointer to a resource type structure.
name Name of the resource to add.
Returns:
Pointer to the resource struct on success and NULL on failure.

resource* res_new_matrix ( resourcetype restype,
int  width,
int  height 
)

Adds a matrix of resources to a resource type.

This function adds width * height new resources to the specified resource type. New resources have names "x y", where x goes from 0 to width -1 and y goes from 0 to height -1. Resources are ordered first by y and then by x.

For example:

 x=resid/height;
 y=resid%height;

If there were no resources added to the resource type before the res_new_matrix() function was called, x now holds the x coordinate and y the y coordinate of the resource with resid resource ID in the matrix.

Parameters:
restype Pointer to a resource type structure.
width Width of the matrix.
height Height of the matrix.
Returns:
Pointer to the last resource struct in the matrix on success and NULL on failure.

void res_set_conflict ( resource res1,
resource res2 
)

Set conflict between resource res1 and resource res2.

Resources must be of the same type. In most cases you must call this function twice:

 res_set_conflict(res1, res2);
 res_set_conflict(res2, res1);

Parameters:
res1 Pointer to the first resource struct.
res2 Pointer to the second resource struct.

resourcetype* restype_find ( char *  type  ) 

Find a resource type by name.

Parameters:
type Name of the resource type to find.
Returns:
Pointer to the resourcetype struct or NULL if this resource type was not found.

int restype_findid ( char *  type  ) 

Find a resource type (either variable or constant) by name and return a resource type ID.

Parameters:
type Name of the resource type to find.
Returns:
Resource type ID or INT_MIN if this resource type was not found.

resourcetype* restype_new ( int  var,
char *  type 
)

Define a new resource type.

Parameters:
var 1 if this is a variable resource type and 0 if this is a constant resource type.
type Name of this resource type (string is duplicated).
Returns:
Pointer to the resourcetype struct or NULL on error.

slist* slist_new ( slist **  list,
int  vartype 
)

Allocate a new slist struct in a linked list.

Linked list is first searched for an identical slist struct. If such a structure is found, only a pointer to it is returned and the linked is is not changed. If no such structure exists, a new structure is allocated and inserted at the beginning of the linked list.

Parameters:
list Pointer to the linked list.
vartype Variable resource type id.
Returns:
Pointer to the new slist struct or NULL on error.

void slist_update ( slist list,
table tab 
)

Update slist with new data from a timetable.

Parameters:
list Pointer to the slist structure to update.
tab Pointer to the table with the new data.

int tuple_compare ( int  tupleid1,
int  tupleid2 
)

Compare two events.

Two events are considered equal (for example, they were defined as repeats of a single <event> tag), if their names are equal and if they have the same constant resources.

Parameters:
tupleid1 Tuple ID of the first event.
tupleid2 Tuple ID of the second event.
Returns:
1 if events are equal or 0 if the are not.

tupleinfo* tuple_new ( char *  name  ) 

Add a new tuple.

After the first tuple was added, any calls to restype_new() and res_new() have unspecified effects.

Tuples are independent by default.

Parameters:
name Name of the tuple (event).
Returns:
Pointer to the tupleinfo struct of the new tuple or NULL on error.

void tuple_set ( tupleinfo tuple,
resource res 
)

Set a resource in a tuple.

Note that only one resource of each type can be used in a tuple.

Parameters:
tuple Pointer to the tupleinfo struct of the tuple to change.
res Pointer to the resource which is used by the tuple.


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