Exemple #1
0
  // set commitment leadtime to a larger number and make sure ordering
  // behavior is correct
  @Test
  public void testGenerateOrders2() {
    // set up the genco with commitment leadtime=3
    PluginConfig config = new PluginConfig("Genco", "").addConfiguration("commitmentLeadtime", "3");
    genco.configure(config); // all defaults
    // capture orders
    final ArrayList<Order> orderList = new ArrayList<Order>();
    doAnswer(
            new Answer() {
              public Object answer(InvocationOnMock invocation) {
                Object[] args = invocation.getArguments();
                orderList.add((Order) args[0]);
                return null;
              }
            })
        .when(mockProxy)
        .routeMessage(isA(Order.class));
    // set up some timeslots
    Timeslot ts0 = timeslotRepo.makeTimeslot(start);
    ts0.disable();
    assertEquals("first ts has sn=0", 0, ts0.getSerialNumber());
    timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR));
    timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR * 2));
    timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR * 3));
    timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR * 4));
    assertEquals("4 enabled timeslots", 4, timeslotRepo.enabledTimeslots().size());

    // generate orders and check
    genco.generateOrders(start, timeslotRepo.enabledTimeslots());
    assertEquals("two orders", 2, orderList.size());
    Order first = orderList.get(0);
    assertEquals("first order for ts3", 3, first.getTimeslot().getSerialNumber());
    assertEquals("first order price", 1.0, first.getLimitPrice(), 1e-6);
    assertEquals("first order for 50 mwh", -100.0, first.getMWh(), 1e-6);
    Order second = orderList.get(1);
    assertEquals("second order for ts4", 4, second.getTimeslot().getSerialNumber());
    assertEquals("second order price", 1.0, second.getLimitPrice(), 1e-6);
    assertEquals("second order for 100 mwh", -100.0, second.getMWh(), 1e-6);
  }
Exemple #2
0
 @Before
 public void setUp() throws Exception {
   Competition.newInstance("Genco test");
   mockProxy = mock(BrokerProxy.class);
   mockSeedRepo = mock(RandomSeedRepo.class);
   seed = mock(RandomSeed.class);
   when(mockSeedRepo.getRandomSeed(eq(Genco.class.getName()), anyInt(), anyString()))
       .thenReturn(seed);
   timeslotRepo = new TimeslotRepo();
   genco = new Genco("Test");
   genco.init(mockProxy, mockSeedRepo);
   start = new DateTime(2011, 1, 1, 12, 0, 0, 0, DateTimeZone.UTC).toInstant();
 }
Exemple #3
0
 @Test
 public void testGenerateOrders() {
   // set up the genco
   PluginConfig config = new PluginConfig("Genco", "");
   genco.configure(config); // all defaults
   // capture orders
   final ArrayList<Order> orderList = new ArrayList<Order>();
   doAnswer(
           new Answer() {
             public Object answer(InvocationOnMock invocation) {
               Object[] args = invocation.getArguments();
               orderList.add((Order) args[0]);
               return null;
             }
           })
       .when(mockProxy)
       .routeMessage(isA(Order.class));
   // set up some timeslots
   Timeslot ts1 = timeslotRepo.makeTimeslot(start);
   ts1.disable();
   Timeslot ts2 = timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR));
   Timeslot ts3 = timeslotRepo.makeTimeslot(start.plus(TimeService.HOUR * 2));
   assertEquals("2 enabled timeslots", 2, timeslotRepo.enabledTimeslots().size());
   // 50 mwh already sold in ts2
   MarketPosition posn2 = new MarketPosition(genco, ts2, -50.0);
   genco.addMarketPosition(posn2, ts2);
   // generate orders and check
   genco.generateOrders(start, timeslotRepo.enabledTimeslots());
   assertEquals("two orders", 2, orderList.size());
   Order first = orderList.get(0);
   assertEquals("first order for ts2", ts2, first.getTimeslot());
   assertEquals("first order price", 1.0, first.getLimitPrice(), 1e-6);
   assertEquals("first order for 50 mwh", -50.0, first.getMWh(), 1e-6);
   Order second = orderList.get(1);
   assertEquals("second order for ts3", ts3, second.getTimeslot());
   assertEquals("second order price", 1.0, second.getLimitPrice(), 1e-6);
   assertEquals("second order for 100 mwh", -100.0, second.getMWh(), 1e-6);
 }
Exemple #4
0
 @Test
 public void testUpdateModel() {
   when(seed.nextDouble()).thenReturn(0.5);
   PluginConfig config = new PluginConfig("Genco", "");
   genco.configure(config); // all defaults
   assertEquals("correct initial capacity", 100.0, genco.getCurrentCapacity(), 1e-6);
   assertTrue("initially in operation", genco.isInOperation());
   genco.updateModel(start);
   assertEquals("correct updated capacity", 100.0, genco.getCurrentCapacity(), 1e-6);
   assertTrue("still in operation", genco.isInOperation());
 }
Exemple #5
0
 @Test
 public void testGenco() {
   assertNotNull("created something", genco);
   assertEquals("correct name", "Test", genco.getUsername());
 }