FLAME’s Future
259
#define _FUNCTIONS_H_
#include "header.h"
/** \def no_firms_to_apply_to
* \brief The number of firms for workers to apply to. */
#define NO_FIRMS_TO_APPLY_TO 10
/** \def no_firms_to_buy_from
* \brief The number of firms for workers to buy goods from. */
#define no_firms_to_buy_from 10
#define printlog 0
#define CHANGEINPRODUCTIVITY 0.0
#define person_firm_distance 50.0
#define firm_mall_distance 50.0
#define person_mall_distance 50.0
#define MESSAGE_RANGE 50.0
#define MALLSNO 3
#define FIRMSNO 5
#define PEOPLENO 30
#define WORKERSNO 30
//Random number generator
inline __device__ float GetRandomNumber(const float minNumber,
const float maxNumber, RNG_rand48* rand48)
{
return minNumber+(rnd(rand48)*(maxNumber-minNumber));
}
/** \fn void bubble_sort(int * id, double * wage, int length)
* \brief Use bubble sorting algorithm to sort worker list by wage
* \param id Pointer to the list of worker ids.
* \param wage Pointer to the associated list of worker wages.
* \param length Length of the lists.
*/
inline __device__ void bubble_sort(int * id, float * wage, int length)
{
int i, j, tmpid;
float tmpwage;
/* Using bubble sorts nested loops */
for(i=0; i<(length-1); i++)
{
for(j=0; j<(length-1)-i; j++)
{
/* Comparing the wages between neighbours */
if(*(wage+j+1) < *(wage+j))
{
/* Check for end of list */
if(*(wage+j+1) != 0)
{
/* Swap worker id and wage to move
cheaper workers to the top of the list */
tmpwage = *(wage+j);
tmpid = *(id+j);
*(wage+j) = *(wage+j+1);
*(id+j) = *(id+j+1);
*(wage+j+1) = tmpwage;
259
#define _FUNCTIONS_H_
#include "header.h"
/** \def no_firms_to_apply_to
* \brief The number of firms for workers to apply to. */
#define NO_FIRMS_TO_APPLY_TO 10
/** \def no_firms_to_buy_from
* \brief The number of firms for workers to buy goods from. */
#define no_firms_to_buy_from 10
#define printlog 0
#define CHANGEINPRODUCTIVITY 0.0
#define person_firm_distance 50.0
#define firm_mall_distance 50.0
#define person_mall_distance 50.0
#define MESSAGE_RANGE 50.0
#define MALLSNO 3
#define FIRMSNO 5
#define PEOPLENO 30
#define WORKERSNO 30
//Random number generator
inline __device__ float GetRandomNumber(const float minNumber,
const float maxNumber, RNG_rand48* rand48)
{
return minNumber+(rnd(rand48)*(maxNumber-minNumber));
}
/** \fn void bubble_sort(int * id, double * wage, int length)
* \brief Use bubble sorting algorithm to sort worker list by wage
* \param id Pointer to the list of worker ids.
* \param wage Pointer to the associated list of worker wages.
* \param length Length of the lists.
*/
inline __device__ void bubble_sort(int * id, float * wage, int length)
{
int i, j, tmpid;
float tmpwage;
/* Using bubble sorts nested loops */
for(i=0; i<(length-1); i++)
{
for(j=0; j<(length-1)-i; j++)
{
/* Comparing the wages between neighbours */
if(*(wage+j+1) < *(wage+j))
{
/* Check for end of list */
if(*(wage+j+1) != 0)
{
/* Swap worker id and wage to move
cheaper workers to the top of the list */
tmpwage = *(wage+j);
tmpid = *(id+j);
*(wage+j) = *(wage+j+1);
*(id+j) = *(id+j+1);
*(wage+j+1) = tmpwage;
