268
X-Machines for Agent-Based Modeling: FLAME Perspectives
current_message = get_next_vacancy_message(current_message,
vacancy_messages);
}
agent->total_vacancies=total_vacancies;
return 0;
}
__FLAME_GPU_FUNC__ int Job_market_b(xmachine_memory_Mall* agent,
xmachine_message_application_list* application_messages,
xmachine_message_employed_list* employed_messages)
{
int i;
int total_free_workers = 0;
int workers[WORKERSNO];
float wages[WORKERSNO];
for(i=0;i
{
workers[i]=0;
wages[i]=0.0f;
}
int count=0;
/* Read application messages */
xmachine_message_application* current_message =
get_first_application_message(application_messages);
while(current_message)
{
/* If the vacancy message refers to this mall*/
if(agent->id == current_message->mall_id)
{
workers[count]=current_message->person_id;
wages[count]= current_message->person_wage;
count++;
total_free_workers++;
}
/* Move onto next message to check */
current_message = get_next_application_message(current_message,
application_messages);
}
/* sort workers cheapest first */
bubble_sort(&workers, &wages, WORKERSNO);
count=0;
while((agent->total_vacancies > 0) && (total_free_workers > 0))
{
/* Loop though firm list */
if(total_free_workers > 0)
{
/* If firm still has vacancies */
if(agent->firm_1_vacancy > 0)
{
add_employed_message(employed_messages,workers[count],
wages[count], agent->firm_1, MESSAGE_RANGE, agent->x,
agent->y, 0.0f);
//remove_int(&workers, 0);
//remove_float(&wages, 0);
total_free_workers--;
agent->total_vacancies--;
agent->firm_1_vacancy= agent->firm_1_vacancy - 1;
X-Machines for Agent-Based Modeling: FLAME Perspectives
current_message = get_next_vacancy_message(current_message,
vacancy_messages);
}
agent->total_vacancies=total_vacancies;
return 0;
}
__FLAME_GPU_FUNC__ int Job_market_b(xmachine_memory_Mall* agent,
xmachine_message_application_list* application_messages,
xmachine_message_employed_list* employed_messages)
{
int i;
int total_free_workers = 0;
int workers[WORKERSNO];
float wages[WORKERSNO];
for(i=0;i
workers[i]=0;
wages[i]=0.0f;
}
int count=0;
/* Read application messages */
xmachine_message_application* current_message =
get_first_application_message(application_messages);
while(current_message)
{
/* If the vacancy message refers to this mall*/
if(agent->id == current_message->mall_id)
{
workers[count]=current_message->person_id;
wages[count]= current_message->person_wage;
count++;
total_free_workers++;
}
/* Move onto next message to check */
current_message = get_next_application_message(current_message,
application_messages);
}
/* sort workers cheapest first */
bubble_sort(&workers, &wages, WORKERSNO);
count=0;
while((agent->total_vacancies > 0) && (total_free_workers > 0))
{
/* Loop though firm list */
if(total_free_workers > 0)
{
/* If firm still has vacancies */
if(agent->firm_1_vacancy > 0)
{
add_employed_message(employed_messages,workers[count],
wages[count], agent->firm_1, MESSAGE_RANGE, agent->x,
agent->y, 0.0f);
//remove_int(&workers, 0);
//remove_float(&wages, 0);
total_free_workers--;
agent->total_vacancies--;
agent->firm_1_vacancy= agent->firm_1_vacancy - 1;
