Exemple #1
0
    def test_load_matpower(self):
        """ Test loading a MATPOWER data file.
        """
        case = Case.load(MP_DATA_FILE, "matpower")

        self.assertEqual(len(case.generators), 3)
        self.assertTrue(isinstance(case, Case))
Exemple #2
0
    def test_infer_matpower_format(self):
        """ Test inference of MATPOWER format from file extension.
        """
        case = Case.load(MP_DATA_FILE)  # Format not specified.

        self.assertEqual(len(case.generators), 3)
        self.assertTrue(isinstance(case, Case))
Exemple #3
0
    def test_infer_matpower_format(self):
        """ Test inference of MATPOWER format from file extension.
        """
        case = Case.load(MP_DATA_FILE) # Format not specified.

        self.assertEqual(len(case.generators), 3)
        self.assertTrue(isinstance(case, Case))
Exemple #4
0
    def test_load_matpower(self):
        """ Test loading a MATPOWER data file.
        """
        case = Case.load(MP_DATA_FILE, "matpower")

        self.assertEqual(len(case.generators), 3)
        self.assertTrue(isinstance(case, Case))
Exemple #5
0
 def setUp(self):
     """ The test runner will execute this method prior to each test.
     """
     self.case = Case.load(join(DATA_DIR, self.case_name,
                                self.case_name + ".pkl"))
     self.case.sort_generators() # ext2int
     self.opf = OPF(self.case, dc=False)
     self.om = self.opf._construct_opf_model(self.case)
     self.solver = PIPSSolver(self.om)
Exemple #6
0
    def setUp(self):
        """ The test runner will execute this method prior to each test.
        """
        self.case = Case.load(DATA_FILE)

        generators = self.case.generators

        self.offers = [
            Offer(generators[0], 12.0, 20.0),
            Offer(generators[0], 24.0, 50.0),
            Offer(generators[0], 24.0, 60.0),

            Offer(generators[1], 12.0, 20.0),
            Offer(generators[1], 24.0, 40.0),
            Offer(generators[1], 24.0, 70.0),

            Offer(generators[2], 12.0, 20.0),
            Offer(generators[2], 24.0, 42.0),
            Offer(generators[2], 24.0, 80.0),

            Offer(generators[3], 12.0, 20.0),
            Offer(generators[3], 24.0, 44.0),
            Offer(generators[3], 24.0, 90.0),

            Offer(generators[4], 12.0, 20.0),
            Offer(generators[4], 24.0, 46.0),
            Offer(generators[4], 24.0, 75.0),

            Offer(generators[5], 12.0, 20.0),
            Offer(generators[5], 24.0, 48.0),
            Offer(generators[5], 24.0, 60.0)
        ]

        self.bids = [
            Bid(generators[6], 10.0, 100.0),
            Bid(generators[6], 10.0, 70.0),
            Bid(generators[6], 10.0, 60.0),

            Bid(generators[7], 10.0, 100.0),
            Bid(generators[7], 10.0, 50.0),
            Bid(generators[7], 10.0, 20.0),

            Bid(generators[8], 10.0, 100.0),
            Bid(generators[8], 10.0, 60.0),
            Bid(generators[8], 10.0, 50.0)
        ]

        self.mkt = SmartMarket(self.case, self.offers, self.bids,
            locationalAdjustment='dc', auctionType=FIRST_PRICE, priceCap=100.0)
Exemple #7
0
    def setUp(self):
        """ The test runner will execute this method prior to each test.
        """
        self.case = Case.load(DATA_FILE)

        generators = self.case.generators

        self.offers = [
            Offer(generators[0], 12.0, 20.0),
            Offer(generators[0], 24.0, 50.0),
            Offer(generators[0], 24.0, 60.0),
            Offer(generators[1], 12.0, 20.0),
            Offer(generators[1], 24.0, 40.0),
            Offer(generators[1], 24.0, 70.0),
            Offer(generators[2], 12.0, 20.0),
            Offer(generators[2], 24.0, 42.0),
            Offer(generators[2], 24.0, 80.0),
            Offer(generators[3], 12.0, 20.0),
            Offer(generators[3], 24.0, 44.0),
            Offer(generators[3], 24.0, 90.0),
            Offer(generators[4], 12.0, 20.0),
            Offer(generators[4], 24.0, 46.0),
            Offer(generators[4], 24.0, 75.0),
            Offer(generators[5], 12.0, 20.0),
            Offer(generators[5], 24.0, 48.0),
            Offer(generators[5], 24.0, 60.0)
        ]

        self.bids = [
            Bid(generators[6], 10.0, 100.0),
            Bid(generators[6], 10.0, 70.0),
            Bid(generators[6], 10.0, 60.0),
            Bid(generators[7], 10.0, 100.0),
            Bid(generators[7], 10.0, 50.0),
            Bid(generators[7], 10.0, 20.0),
            Bid(generators[8], 10.0, 100.0),
            Bid(generators[8], 10.0, 60.0),
            Bid(generators[8], 10.0, 50.0)
        ]

        self.mkt = SmartMarket(self.case,
                               self.offers,
                               self.bids,
                               locationalAdjustment='dc',
                               auctionType=FIRST_PRICE,
                               priceCap=100.0)
Exemple #8
0
""" This example demonstrates how to solve an OPF problem. """

import sys
import logging

from os.path import join, dirname

import pylon.case
from pylon import Case, OPF

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

# Define a path to the data file.
CASE_FILE = join(dirname(pylon.case.__file__), "test", "data", "case30pwl",
                 "case30pwl.pkl")

# Load the data file.
case = Case.load(CASE_FILE)

case.generators[2].pwl_to_poly()

# Use DC formulation?
dc = False

# Solve DC optimal power flow.
OPF(case, dc, opt={"verbose": True}).solve()

# Print a report to screen.
case.save_rst(sys.stdout)
Exemple #9
0
 def setUp(self):
     """ The test runner will execute this method prior to each test.
     """
     self.case = Case.load(join(DATA_DIR, self.case_name,
                                self.case_name + ".pkl"))
Exemple #10
0
 def setUp(self):
     """ The test runner will execute this method prior to each test.
     """
     self.case = Case.load(POLY_FILE)
     self.opf = OPF(self.case)
Exemple #11
0
def getPickledCase():
    """ Returns a test power system case.
    """
    # Read case from data file.
    return Case.load(DATA_FILE)
Exemple #12
0
def getPickledCase():
    """ Returns a test power system case.
    """
    # Read case from data file.
    return Case.load(DATA_FILE)
Exemple #13
0
__author__ = 'Richard Lincoln, [email protected]'
""" This example demonstrates profiling an OPF problem. """

from os.path import join, dirname

import cProfile
import pstats

import pylon.case
from pylon import Case, OPF  #@UnusedImport

# Define a path to the data file.
CASE_FILE = join(dirname(pylon.case.__file__), "test", "data", "case30pwl.pkl")

# Load the data file.
case = Case.load(CASE_FILE)

cProfile.run("OPF(case, dc=False, opt={'verbose': True}).solve()", "opf_prof")

p = pstats.Stats("opf_prof")
#p.sort_stats('name').print_stats()
p.sort_stats('cumulative').print_stats(20)
#p.sort_stats('time').print_stats(20)
#p.sort_stats('time', 'cum').print_stats(.5, 'init')
Exemple #14
0
 def setUp(self):
     """ The test runner will execute this method prior to each test.
     """
     self.case = Case.load(join(DATA_DIR, self.case_name, self.case_name + ".pkl"))
Exemple #15
0
from pylon import Case, OPF

from pybrain.rl.agents import LearningAgent
from pybrain.rl.learners import ENAC, Reinforce
from pybrain.tools.shortcuts import buildNetwork
from pybrain.tools.plotting import MultilinePlotter
from pybrain.structure import TanhLayer, LinearLayer #@UnusedImport

logger = logging.getLogger()
for handler in logger.handlers: logger.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
logger.setLevel(logging.DEBUG)

# Saved case formats are recognised by file extension.
case = Case.load("../data/case6ww.pkl")

#case.generators[0].p_cost = (0.0, 9.0, 200.0)
#case.generators[1].p_cost = (0.0, 2.0, 200.0)
#case.generators[2].p_cost = (0.0, 5.0, 200.0)

case.generators[0].p_cost = (0.0, 5.0, 200.0)
case.generators[1].p_cost = (0.0, 7.0, 200.0)
case.generators[2].p_cost = (0.0, 2.0, 200.0)

case.generators[0].c_shutdown = 100.0

case.generators[0].p_max = 100.0
case.generators[1].p_max = 70.0
case.generators[2].p_max = 70.0