Primary competition visual

Smart Energy Supply Scheduling for Green Telecom Challenge by ITU

18 000 CHF
Completed (over 1 year ago)
Prediction
833 joined
158 active
Starti
Aug 06, 24
Closei
Sep 30, 24
Reveali
Oct 03, 24
Is the scoring function errorMetric_ex.py even running?
Help · 29 Sep 2024, 07:37 · 1

When I run the scoring function, I get this error:

line 196, in calcSingleSiteScore

solarPower = config["solarPower"][str(i // 4)] if batteryStatus["useSolar"] else 0.0

KeyError: '0'

Anyone else facing the same issue and know how to resolve it?

Discussion 1 answer
User avatar
J0NNY

If you are testing the scoring function locally, you need to convert the time column to an int, then string

def prepare_testing_data(test_energy_path, test_solar_path, site_config_path, fname='test_energy_solarx.csv'):
    test_energy = pd.read_csv(test_energy_path)[['Site Name','Day', 'Hour', 'Total Energy(kWh)']]
    test_solar = pd.read_csv(test_solar_path)[['Site Name','Day', 'Hour', 'Energy Output(kWh)']]
    test_energy['time'] = (test_energy['Day']-54) * 24 + test_energy['Hour']
    test_solar['time'] = (test_solar['Day']-54) * 24 + test_solar['Hour']
    test_energy = test_energy.drop(columns=['Day', 'Hour'])
    test_solar = test_solar.drop(columns=['Day', 'Hour'])
    # merge the energy and solar
    test_energy_solar = pd.merge(test_energy, test_solar, on=['Site Name', 'time'], how='inner')
    test_energy_solar.sort_values(by=['Site Name', 'time'], inplace=True)
    test_energy_solar['time'] = test_energy_solar.time.astype(int).astype(str)
    test_energy_solar = test_energy_solar[['Site Name', 'time', 'Total Energy(kWh)', 'Energy Output(kWh)']].reset_index(drop=True)
    # add the site config to the last
    site_config = pd.read_csv(site_config_path)
    values_to_add = site_config.values.tolist()
    test_energy_solar = pd.concat([test_energy_solar, pd.DataFrame(values_to_add, columns=['Site Name', 'time', 'Total Energy(kWh)', 'Energy Output(kWh)']+list(range(6)))], ignore_index=True)
    # display(test_energy_solar)
    test_energy_solar.to_csv(fname, index=False)
29 Sep 2024, 08:00
Upvotes 3