260
X-Machines for Agent-Based Modeling: FLAME Perspectives
*(id+j+1) = tmpid;
}
}
}
}
}
/** \fn void bubble_sort(int * id, double * wage, int length)
* \brief Use bubble sorting algorithm to sort worker 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.
*/
void sort_prices(int * id, int * stock, float * price, int length)
{
int i, j, tmpid, tmpstock;
float tmpprice;
/* 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(*(price+j+1) < *(price+j))
{
/* Check for end of list */
if(*(price+j+1) != 0)
{
/* Swap worker id and wage to move
cheaper workers to the top of the list */
tmpprice = *(price+j);
tmpid = *(id+j);
tmpstock = *(stock+j);
*(price+j) = *(price+j+1);
*(id+j) = *(id+j+1);
*(stock+j) = *(stock+j+1);
*(price+j+1) = tmpprice;
*(id+j+1) = tmpid;
*(stock+j+1) = tmpstock;
}
}
}
}
}
/** \fn Firm_1()
* \brief Set initial values of financial viability, production
*\ and number of labour required during every iteration
*/
__FLAME_GPU_FUNC__ int Firm_1(xmachine_memory_Firm* agent,
xmachine_message_vacancy_list* vacancy_messages,RNG_rand48* rand48)
{
float mean=0.0f;
float random_no=rnd(rand48);
int mall_chosen;
Précédent

- 289/329

Suivant