Exemplo n.º 1
0
def run_2(num_of_agents, noise, values):

     print('start calculating agents-{0} , noise-{1},  {2}'.format(num_of_agents, noise, datetime.utcnow()))

     identical_values = numbersUtils.values_to_allocations(numbersUtils.noisy_values_array(values, 0, None, num_of_agents))

     noise_values = numbersUtils.values_to_allocations(numbersUtils.noisy_values_array(values, noise, None, num_of_agents))

     index_to_location_type = envinfluence.index_to_location_type(values, envinfluence. LOCATION_TYPES())

     env_influence_values = numbersUtils.values_to_allocations(numbersUtils.preferences_values_array(values, index_to_location_type, None,  num_of_agents))

     ldResults = calc_single_row(num_of_agents, noise, deepcopy(noise_values), deepcopy(identical_values), deepcopy(env_influence_values), LastDiminisher.last_diminisher_allocation)

     print('ldResults calculated {0}'.format(datetime.utcnow()))

     evenPazResults = calc_single_row(num_of_agents, noise, deepcopy(noise_values), deepcopy(identical_values), deepcopy(env_influence_values), evenpazalg.even_paz_dividion)

     print('evenPazResults calculated {0}'.format(datetime.utcnow()))

     return  evenPazResults,ldResults
Exemplo n.º 2
0
def run_ex_for_params(num_of_agents, noise, values):
    results_by_exp_type = {}

    for exp_type in expType.ExperimentType:
        results_by_exp_type[exp_type] =[]

    identical_values = numbersUtils.noisy_values_array(values, 0, None, num_of_agents)


    for exp in range(EXPERIMENTS_PER_CELL):
        noise_values = numbersUtils.noisy_values_array(values, noise, None, num_of_agents)

        allocations1  = numbersUtils.values_to_allocations(noise_values)
        identical_allocation_even_paz = numbersUtils.values_to_allocations(identical_values)

        #even paz..
        results_even_paz = calc_results_with_exchnages(evenpazalg.even_paz_dividion, expType.ExperimentType.even_paz, expType.ExperimentType.even_paz_exchange_jealous, allocations1,
                                                       num_of_agents, noise, None, identical_allocation_even_paz, expType.ExperimentType.even_paz_appraiser, results_by_exp_type)


        allocations2  = numbersUtils.values_to_allocations(noise_values)
        identical_allocation_last_diminisher = numbersUtils.values_to_allocations(identical_values)

        #last diminisher
        calc_results_with_exchnages(LastDiminisher.last_diminisher_allocation, expType.ExperimentType.last_diminisher, expType.ExperimentType.last_diminisher_exchange_jealous,
                                    allocations2, num_of_agents, noise, None, identical_allocation_last_diminisher, expType.ExperimentType.last_diminisher_appraiser, results_by_exp_type)

        #env influence
        index_to_location_type = envinfluence.index_to_location_type(values, envinfluence. LOCATION_TYPES())

        env_influence_values = numbersUtils.preferences_values_array(values, index_to_location_type, None,  num_of_agents)

        #even paz
        even_paz_env_allocations = numbersUtils.values_to_allocations(env_influence_values)
        calc_results_with_exchnages(evenpazalg.even_paz_dividion, expType.ExperimentType.even_paz_env_influence, expType.ExperimentType.even_paz_env_influence_exchange,
                                    even_paz_env_allocations, num_of_agents, 0, None, None, None, results_by_exp_type)


        #last diminisher
        last_diminisher_env_allocations = numbersUtils.values_to_allocations(env_influence_values)
        calc_results_with_exchnages(LastDiminisher.last_diminisher_allocation, expType.ExperimentType.last_diminisher_env_influence, expType.ExperimentType.last_diminisher_env_influence_exchange,
                                    last_diminisher_env_allocations, num_of_agents, 0, None, None, None, results_by_exp_type)

        #fraud agent

        for i in range(num_of_agents):

           identical_allocation_last_diminisher_i = numbersUtils.values_to_allocations(identical_values)

           allocations_even_paz_fraud  = numbersUtils.values_to_allocations(noise_values)

           calc_results_with_exchnages(evenpazalg.even_paz_dividion, expType.ExperimentType.even_paz_fraud_agent_index,
                                        expType.ExperimentType.even_paz_fraud_agent_index_with_exchange, allocations_even_paz_fraud, num_of_agents, noise, i,
                                        identical_allocation_last_diminisher_i, expType.ExperimentType.even_paz_fraud_identical, results_by_exp_type)

           allocations_last_diminisher_fraud = numbersUtils.values_to_allocations(noise_values)

           calc_results_with_exchnages(LastDiminisher.last_diminisher_allocation, expType.ExperimentType.last_diminisher_fraud_agent_index,
                                       expType.ExperimentType.last_diminisher_fraud_agent_index_with_exchange, allocations_last_diminisher_fraud, num_of_agents, noise, i,
                                       identical_allocation_last_diminisher_i, expType.ExperimentType.last_diminisher_fraud_identical, results_by_exp_type)



    #calc mid

    for type, results in results_by_exp_type.items():
        for result in results:
            #todo: calc average from same type of alg..
            pass

    return results_by_exp_type