Example #1
0
    def output_results(self, final=False):

        (best_gene, best_gene_data) = self.algorithm.get_final()

        if len(best_gene) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_gene)

            if 'demand' in self.dispatch_order:
                ts_demand = results['other']['demand']['ts_demand']
            else:
                ts_demand = self.data.get_timeseries('ts_demand')

            # and print out the text strings, accompanied by the costs
            strings = results['gen_desc']
            costs = results['cost']
            total_cost = 0.0
            for gen in results['cost'].iterkeys():
                info = strings[gen]
                cost = costs[gen]
                total_cost += cost
                logger.info(gen + ' ($M {:.2f}) : '.format(cost) + info)

            logger.info('Total cost ($M): {:.2f}'.format(total_cost))
        else:
            results = None

        pickle_dict = {}
        pickle_dict['best_gene_data'] = best_gene_data
        pickle_dict['best_gene'] = best_gene

        full_conf = self.get_full_config()
        mureiloutput.clean_config_for_pickle(full_conf)
        pickle_dict['config'] = full_conf

        pickle_dict['best_results'] = results
        pickle_dict['ts_demand'] = ts_demand

        if self.config['do_plots']:
            mureiloutput.plot_timeseries(results['output'], ts_demand, final)

        output_file = self.config['output_file']
        mureiloutput.pickle_out(pickle_dict, output_file)

        return results
    def output_results(self, final=False):

        (best_gene, best_gene_data) = self.algorithm.get_final()

        if len(best_gene) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_gene)

            if "demand" in self.dispatch_order:
                ts_demand = results["other"]["demand"]["ts_demand"]
            else:
                ts_demand = self.data.get_timeseries("ts_demand")

            # and print out the text strings, accompanied by the costs
            strings = results["gen_desc"]
            costs = results["cost"]
            total_cost = 0.0
            for gen in results["cost"].iterkeys():
                info = strings[gen]
                cost = costs[gen]
                total_cost += cost
                logger.info(gen + " ($M {:.2f}) : ".format(cost) + info)

            logger.info("Total cost ($M): {:.2f}".format(total_cost))
        else:
            results = None

        pickle_dict = {}
        pickle_dict["best_gene_data"] = best_gene_data
        pickle_dict["best_gene"] = best_gene

        full_conf = self.get_full_config()
        mureiloutput.clean_config_for_pickle(full_conf)
        pickle_dict["config"] = full_conf

        pickle_dict["best_results"] = results
        pickle_dict["ts_demand"] = ts_demand

        if self.config["do_plots"]:
            mureiloutput.plot_timeseries(results["output"], ts_demand, final)

        output_file = self.config["output_file"]
        mureiloutput.pickle_out(pickle_dict, output_file)

        return results
    def output_results(self, final=False, iteration=0):

        (best_params, opt_data) = self.algorithm.get_final()

        if len(best_params) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_params)

            logger.info(
                '======================================================')
            logger.info(
                'Total cost ($M): {:.2f}, including carbon (MT): {:.2f}, terminal value ($M): {:.2f}'
                .format(results['totals']['cost'],
                        results['totals']['carbon'] * 1e-6,
                        results['totals']['terminal_value']))
            logger.info(
                '======================================================')

            ts_demand = {}

            # Now iterate across the periods, and then across the generators
            for period in self.run_periods:
                period_results = results['periods'][period]
                logger.info(
                    '------------------------------------------------------')
                logger.info('PERIOD ' + str(period) + ':')
                logger.info(
                    '------------------------------------------------------')
                logger.info(
                    'Period cost ($M): {:.2f}, carbon (MT): {:.2f}'.format(
                        period_results['totals']['cost'],
                        period_results['totals']['carbon'] * 1e-6))

                if 'demand' in self.dispatch_order:
                    ts_demand[period] = period_results['generators']['demand'][
                        'other']['ts_demand']
                else:
                    ts_demand[period] = self.data.get_timeseries('ts_demand')

                period_results['totals']['demand'] = (
                    numpy.sum(ts_demand[period]) *
                    self.global_config['time_scale_up_mult'] *
                    self.global_config['timestep_hrs'])
                logger.info('Period total demand (GWh): {:.2f}'.format(
                    period_results['totals']['demand'] / 1000))

                for gen_type, value in period_results['generators'].iteritems(
                ):
                    gen_string = value['desc_string']
                    gen_cost = value['cost']
                    gen_supply = value['total_supply_period']
                    logger.info(gen_type +
                                ' ($M {:.2f}, GWh {:.2f}) : '.format(
                                    gen_cost, gen_supply / 1000) + gen_string)

            logger.info(
                '======================================================')

            pickle_dict = {}
            pickle_dict['opt_data'] = opt_data
            pickle_dict['best_params'] = best_params

            full_conf = self.get_full_config()
            mureiloutput.clean_config_for_pickle(full_conf)
            pickle_dict['config'] = full_conf

            pickle_dict['best_results'] = results
            pickle_dict['ts_demand'] = ts_demand

            if self.config['do_plots']:
                for period in self.run_periods:
                    plot_data = {}
                    for gen_type, value in results['periods'][period][
                            'generators'].iteritems():
                        plot_data[gen_type] = value['aggregate_supply']

                    this_final = final and (period
                                            == self.config['run_periods'][-1])
                    mureiloutput.plot_timeseries(
                        plot_data,
                        ts_demand[period],
                        this_final,
                        plot_title=(str(period) + ' at iteration ' +
                                    str(iteration)))

            output_file = self.config['output_file']
            mureiloutput.pickle_out(pickle_dict, output_file)
        else:
            results = None

        return results
Example #4
0
    def output_results(self, final=False, iteration=0):
    
        (best_params, opt_data) = self.algorithm.get_final()

        if len(best_params) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_params)

            
            if 'dispatch_fail' in results:
                logger.info('======================================================')
                logger.info('Dispatch failed.')
                logger.info('======================================================')
            else:
                logger.info('======================================================')
                logger.info('Total cost ($M): {:.2f}, including carbon (MT): {:.2f}, terminal value ($M): {:.2f}'.format(
                    results['totals']['cost'], results['totals']['carbon'] * 1e-6, results['totals']['terminal_value']))
                logger.info('======================================================')

                ts_demand = {}

                # Now iterate across the periods, and then across the generators
                for period in self.run_periods:
                    period_results = results['periods'][period]
                    logger.info('------------------------------------------------------')
                    logger.info('PERIOD ' + str(period) + ':')
                    logger.info('------------------------------------------------------')
                    logger.info('Period cost ($M): {:.2f}, carbon (MT): {:.2f}'.format(
                        period_results['totals']['cost'], 
                        period_results['totals']['carbon'] * 1e-6))

                    for gen_type, value in period_results['generators'].iteritems():
                        gen_string = value['desc_string']
                        gen_cost = value['cost']
                        gen_supply = value['total_supply_period']
                        logger.info(gen_type + ' ($M {:.2f}, GWh {:.2f}) : '.format(
                            gen_cost, gen_supply / 1000) + gen_string)

                    logger.info('Total connection cost: $M {:.2f}'.format(
                        period_results['transmission']['connection_cost_total']))
                    logger.info('Total system demand: GWh {:.2f}'.format(
                        period_results['totals']['demand'] / 1000))
                    logger.info('Total unserved energy: GWh {:.2f}'.format(
                        period_results['demand']['unserved_energy_total'] / 1000))

                logger.info('======================================================')

            pickle_dict = {}
            pickle_dict['opt_data'] = opt_data
            pickle_dict['best_params'] = best_params

            full_conf = self.get_full_config()
            mureiloutput.clean_config_for_pickle(full_conf)
            pickle_dict['config'] = full_conf

            pickle_dict['best_results'] = results

            if self.config['do_plots']:
                if 'dispatch_fail' not in results:
                    for period in self.run_periods:
                        plot_data = {}
                        for gen_type, value in results['periods'][period]['generators'].iteritems():
                            plot_data[gen_type] = value['aggregate_supply']
            
                        ts_demand = results['periods'][period]['demand']['aggregate_ts']

                        this_final = final and (period == self.config['run_periods'][-1])
                        mureiloutput.plot_timeseries(plot_data, 

                            ts_demand, this_final, plot_title=(

                                str(period) + ' at iteration ' + str(iteration)))

            output_file = self.config['output_file']
            mureiloutput.pickle_out(pickle_dict, output_file)
        else:
Example #5
0
    def output_results(self, final=False, iteration=0):

        (best_params, opt_data) = self.algorithm.get_final()

        if len(best_params) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_params)

            if 'dispatch_fail' in results:
                logger.info(
                    '======================================================')
                logger.info('Dispatch failed.')
                logger.info(
                    '======================================================')
            else:
                logger.info(
                    '======================================================')
                logger.info(
                    'Total cost ($M): {:.2f}, including carbon (MT): {:.2f}, terminal value ($M): {:.2f}'
                    .format(results['totals']['cost'],
                            results['totals']['carbon'] * 1e-6,
                            results['totals']['terminal_value']))
                logger.info(
                    '======================================================')

                ts_demand = {}

                # Now iterate across the periods, and then across the generators
                for period in self.run_periods:
                    period_results = results['periods'][period]
                    logger.info(
                        '------------------------------------------------------'
                    )
                    logger.info('PERIOD ' + str(period) + ':')
                    logger.info(
                        '------------------------------------------------------'
                    )
                    logger.info(
                        'Period cost ($M): {:.2f}, carbon (MT): {:.2f}'.format(
                            period_results['totals']['cost'],
                            period_results['totals']['carbon'] * 1e-6))

                    for gen_type, value in period_results[
                            'generators'].iteritems():
                        gen_string = value['desc_string']
                        gen_cost = value['cost']
                        gen_supply = value['total_supply_period']
                        logger.info(gen_type +
                                    ' ($M {:.2f}, GWh {:.2f}) : '.format(
                                        gen_cost, gen_supply / 1000) +
                                    gen_string)

                    logger.info('Total connection cost: $M {:.2f}'.format(
                        period_results['transmission']
                        ['connection_cost_total']))
                    logger.info('Total system demand: GWh {:.2f}'.format(
                        period_results['totals']['demand'] / 1000))
                    logger.info('Total unserved energy: GWh {:.2f}'.format(
                        period_results['demand']['unserved_energy_total'] /
                        1000))

                logger.info(
                    '======================================================')

            pickle_dict = {}
            pickle_dict['opt_data'] = opt_data
            pickle_dict['best_params'] = best_params

            full_conf = self.get_full_config()
            mureiloutput.clean_config_for_pickle(full_conf)
            pickle_dict['config'] = full_conf

            pickle_dict['best_results'] = results

            if self.config['do_plots']:
                if 'dispatch_fail' not in results:
                    for period in self.run_periods:
                        plot_data = {}
                        for gen_type, value in results['periods'][period][
                                'generators'].iteritems():
                            plot_data[gen_type] = value['aggregate_supply']

                        ts_demand = results['periods'][period]['demand'][
                            'aggregate_ts']

                        this_final = final and (
                            period == self.config['run_periods'][-1])
                        mureiloutput.plot_timeseries(
                            plot_data,
                            ts_demand,
                            this_final,
                            plot_title=(str(period) + ' at iteration ' +
                                        str(iteration)))

            output_file = self.config['output_file']
            mureiloutput.pickle_out(pickle_dict, output_file)
        else:
            results = None

        return results
    def output_results(self, final=False, iteration=0):
    
        (best_params, opt_data) = self.algorithm.get_final()

        if len(best_params) > 0:
            # Protect against an exception before there are any params
            results = self.evaluate_results(best_params)

            logger.info('======================================================')
            logger.info('Total cost ($M): {:.2f}, including carbon (MT): {:.2f}, terminal value ($M): {:.2f}'.format(
                results['totals']['cost'], results['totals']['carbon'] * 1e-6, results['totals']['terminal_value']))
            logger.info('======================================================')

            ts_demand = {}
    
            # Now iterate across the periods, and then across the generators
            for period in self.run_periods:
                period_results = results['periods'][period]
                logger.info('------------------------------------------------------')
                logger.info('PERIOD ' + str(period) + ':')
                logger.info('------------------------------------------------------')
                logger.info('Period cost ($M): {:.2f}, carbon (MT): {:.2f}'.format(
                    period_results['totals']['cost'], 
                    period_results['totals']['carbon'] * 1e-6))

                if 'demand' in self.dispatch_order:
                    ts_demand[period] = period_results['generators']['demand']['other']['ts_demand']
                else:
                    ts_demand[period] = self.data.get_timeseries('ts_demand')
            
                period_results['totals']['demand'] = (numpy.sum(ts_demand[period]) *
                    self.global_config['time_scale_up_mult'] * self.global_config['timestep_hrs'])
                logger.info('Period total demand (GWh): {:.2f}'.format(
                    period_results['totals']['demand'] / 1000))

                for gen_type, value in period_results['generators'].iteritems():
                    gen_string = value['desc_string']
                    gen_cost = value['cost']
                    gen_supply = value['total_supply_period']
                    logger.info(gen_type + ' ($M {:.2f}, GWh {:.2f}) : '.format(
                        gen_cost, gen_supply / 1000) + gen_string)

            logger.info('======================================================')

            pickle_dict = {}
            pickle_dict['opt_data'] = opt_data
            pickle_dict['best_params'] = best_params

            full_conf = self.get_full_config()
            mureiloutput.clean_config_for_pickle(full_conf)
            pickle_dict['config'] = full_conf

            pickle_dict['best_results'] = results
            pickle_dict['ts_demand'] = ts_demand

            if self.config['do_plots']:
                for period in self.run_periods:
                    plot_data = {}
                    for gen_type, value in results['periods'][period]['generators'].iteritems():
                        plot_data[gen_type] = value['aggregate_supply']
                        
                    this_final = final and (period == self.config['run_periods'][-1])
                    mureiloutput.plot_timeseries(plot_data, 

                        ts_demand[period], this_final, plot_title=(

                            str(period) + ' at iteration ' + str(iteration)))

            output_file = self.config['output_file']
            mureiloutput.pickle_out(pickle_dict, output_file)
        else:
            results = None