import csv import random import math def get_demand_table(product_number): path = 'data/fc_experiment/demand_history.csv' number_periods = 10 ma10 = 0 actual_demand = 0 demand_data = [] mu = 0 sigma = 0 min_level = 0 max_level = 0 reg_a = 0 reg_b = 0 reg_p = 0 with open(path) as csv_file: csv_reader = csv.reader(csv_file, delimiter=';') line_count = 0 demand_table = '
| Period | ' for r in range(1,number_periods+2): # demand_table += '' + str(r) + ' | ' demand_table += '' #Second row with demands demand_table += ' | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Demand [units] | '
for row in csv_reader:
if line_count == product_number:
mu = int(f'{row[1]}')
sigma = int(f'{row[2]}')
min_level = int(f'{row[3]}')
max_level = int(f'{row[4]}')
ma10 = int(f'{row[5]}')
reg_a = int(f'{row[6]}')
reg_b = int(f'{row[7]}')
reg_p = float(f'{row[8]}')
demand_table += '' + f'{row[9]}' +' | ' demand_table += '' + f'{row[10]}' +' | ' demand_table += '' + f'{row[11]}' +' | ' demand_table += '' + f'{row[12]}' +' | ' demand_table += '' + f'{row[13]}' +' | ' demand_table += '' + f'{row[14]}' +' | ' demand_table += '' + f'{row[15]}' +' | ' demand_table += '' + f'{row[16]}' +' | ' demand_table += '' + f'{row[17]}' +' | ' demand_table += '' + f'{row[18]}' +' | ' demand_table += '' + '?' +' | ' demand_data.append(int(f'{row[9]}')) demand_data.append(int(f'{row[10]}')) demand_data.append(int(f'{row[11]}')) demand_data.append(int(f'{row[12]}')) demand_data.append(int(f'{row[13]}')) demand_data.append(int(f'{row[14]}')) demand_data.append(int(f'{row[15]}')) demand_data.append(int(f'{row[16]}')) demand_data.append(int(f'{row[17]}')) demand_data.append(int(f'{row[18]}')) actual_demand = int(f'{row[19]}') line_count += 1 else: line_count += 1 demand_table += '
| Period t | ' nn_table += 'Demand | ' nn_table += 'Normed Demand | ' nn_table += 'Weight | ' nn_table += 'Weighted Normed Demand | ' nn_table += '
|---|---|---|---|---|
| ' + str(i) + ' | ' nn_table += '' + str(demand_data[i-1]) + ' | ' nn_table += '' + str(round(normed_demand[i],3)) + ' | ' nn_table += '' + str(round(weight[i],3)) + ' | ' nn_table += '' + str(round(weighted_normed_demand[i],3)) + ' | ' nn_table += '
| Bias | ' nn_table += '' nn_table += ' | 1.000 | ' nn_table += '' + str(round(bias_weight,3)) + ' | ' nn_table += '' + str(round(bias_weight,3)) + ' | ' nn_table += '' #Demand Forecast normalized nn_table += ' |
| ' nn_table += ' | Demand forecast for period 11 (normed) | ' nn_table += '' + str(round(demand_forecast_period_11_normed,3)) + ' | ' nn_table += '||
| ' nn_table += ' | Demand forecast for period 11 | ' nn_table += '' + str(int(round(demand_forecast_period_11,0))) + ' | ' nn_table += '' nn_table += ' | |
| ' + text_at_top + ' | ' table += 'Strongly disagree | ' table += 'Disagree | ' table += 'Somewhat disagree | ' table += 'Neither agree nor disagree | ' table += 'Somewhat agree | ' table += 'Agree | ' table += 'Strongly agree | ' # table += 'Aussage | ' # table += 'Trifft überhaupt nicht zu | ' # table += 'Trifft nicht zu | ' # table += 'Trifft eher nicht zu | ' # table += 'Teils-teils | ' # table += 'Trifft eher zu | ' # table += 'Trifft zu | ' # table += 'Trifft voll zu | ' table += '' question_counter = 0 likert_scale_number = 7 for q in question_order: question_counter += 1 table += ' |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ' + str(questions[q-1]) + ' | ' for l in range(1,likert_scale_number+1): table += '' table += ' | ' table += ' |
| ' + text_at_top + ' | ' table += 'Much less than appropriate | ' table += 'Less than appropriate | ' table += 'A bit less than appropriate | ' table += 'Appropriate | ' table += 'A bit more than appropriate | ' table += 'More than appropriate | ' table += 'Much more than appropriate | ' # table += 'Aussage | ' # table += 'Trifft überhaupt nicht zu | ' # table += 'Trifft nicht zu | ' # table += 'Trifft eher nicht zu | ' # table += 'Teils-teils | ' # table += 'Trifft eher zu | ' # table += 'Trifft zu | ' # table += 'Trifft voll zu | ' table += '' question_counter = 0 likert_scale_number = 7 for q in question_order: question_counter += 1 table += ' |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ' + str(questions[q-1]) + ' | ' for l in range(1,likert_scale_number+1): table += '' table += ' | ' table += ' |
| Product | '
payoff_table += 'Your forecast [units] | '
payoff_table += 'Actual demand [units] | '
payoff_table += 'Forecast error | '
payoff_table += 'Reward [USD] | '
payoff_table += '|
|---|---|---|---|---|---|
| ' for r in range(1,len(product_order)+1): payoff_table += ' | |||||
| ' + str(r) + ' | ' payoff_table += '' + str(self.participant.vars['second_judgement_' + str(product_order[r-1])]) + ' | ' payoff_table += '' + str(self.participant.vars['actual_demand_' + str(product_order[r-1])]) + ' | ' payoff_table += '' + str(round(self.participant.vars['forecast_error_' + str(product_order[r-1])],3)) + ' | ' payoff_table += '' + str(self.participant.vars['payoff_' + str(product_order[r-1])]) + ' | ' payoff_table += '|
| ' payoff_table += ' | |||||
| ' payoff_table += ' | ' payoff_table += ' | ' payoff_table += ' | Bonus reward: | ' payoff_table += '' + str( self.participant.payoff_plus_participation_fee() - self.session.config['participation_fee']) + ' | ' payoff_table += '|
| ' payoff_table += ' | ' payoff_table += ' | ' payoff_table += ' | Fixed reward: | ' payoff_table += '' + str(self.session.config['participation_fee']) + ' | ' payoff_table += '|
| ' payoff_table += ' | |||||
| ' payoff_table += ' | ' payoff_table += ' | ' payoff_table += ' | Total reward: | ' payoff_table += '' + str(self.participant.payoff_plus_participation_fee()) + ' | ' payoff_table += '|