264
X-Machines for Agent-Based Modeling: FLAME Perspectives
/* Set the stock amount */
agent->stock=current_message->stock;
/* Exit stock message list */
current_message = NULL;
}
/* Else carry on reading stock messages */
else
current_message = get_next_firm_stock_message
(current_message,firm_stock_messages);
}
/* Set the amount of stock sold */
agent->sold=agent->goodsproduced - agent->stock;
/* Calculate the revenue earned by the firm */
revenue = (agent->goodsproduced - agent->stock) * agent->price;
/* Calculate wage bill DONE EARLIER
for(i=0;inumberofworkers;i++)
{
totalwagebill += xmemory->workerwage.array[i];
}*/
/* Calculate the profits */
agent->profits=revenue-agent->totalwagebill;
/* Calculate R&D fraction */
/* Calculate net worth */
/* Calculate the average wage, just for information */
if(agent->numberofworkers == 0)
{
ave_wage = 0;
}
else
{
ave_wage = agent->totalwagebill/(float)agent->numberofworkers;
}
agent->avewage=ave_wage;
/* Print results as simulation progresses */
return 0;
}
/** \fn Person_1()
* \brief Calculates new wage and sends job applications
*/
__FLAME_GPU_FUNC__ int Person_1(xmachine_memory_Person* agent,
xmachine_message_priceinflation_list* priceinflation_messages,
xmachine_message_application_list* application_messages,
RNG_rand48* rand48)
{
int number_of_firms;
int m = NO_FIRMS_TO_APPLY_TO;
float price_inflation = 0.0f;
int mall_chosen=0;
number_of_firms = 0;
xmachine_message_priceinflation* current_message =
get_first_priceinflation_message(priceinflation_messages);
while(current_message)
{
X-Machines for Agent-Based Modeling: FLAME Perspectives
/* Set the stock amount */
agent->stock=current_message->stock;
/* Exit stock message list */
current_message = NULL;
}
/* Else carry on reading stock messages */
else
current_message = get_next_firm_stock_message
(current_message,firm_stock_messages);
}
/* Set the amount of stock sold */
agent->sold=agent->goodsproduced - agent->stock;
/* Calculate the revenue earned by the firm */
revenue = (agent->goodsproduced - agent->stock) * agent->price;
/* Calculate wage bill DONE EARLIER
for(i=0;i
{
totalwagebill += xmemory->workerwage.array[i];
}*/
/* Calculate the profits */
agent->profits=revenue-agent->totalwagebill;
/* Calculate R&D fraction */
/* Calculate net worth */
/* Calculate the average wage, just for information */
if(agent->numberofworkers == 0)
{
ave_wage = 0;
}
else
{
ave_wage = agent->totalwagebill/(float)agent->numberofworkers;
}
agent->avewage=ave_wage;
/* Print results as simulation progresses */
return 0;
}
/** \fn Person_1()
* \brief Calculates new wage and sends job applications
*/
__FLAME_GPU_FUNC__ int Person_1(xmachine_memory_Person* agent,
xmachine_message_priceinflation_list* priceinflation_messages,
xmachine_message_application_list* application_messages,
RNG_rand48* rand48)
{
int number_of_firms;
int m = NO_FIRMS_TO_APPLY_TO;
float price_inflation = 0.0f;
int mall_chosen=0;
number_of_firms = 0;
xmachine_message_priceinflation* current_message =
get_first_priceinflation_message(priceinflation_messages);
while(current_message)
{
