Charge for production

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Charge for production

Jasper
Dear all,

I noted something in the source code of the server that I don't understand. When I look in the broker.trace file of the sample broker I see that the charges for both consumption and production are positive. For example:

<tariff-tx id="2401" txType="PRODUCE" customerCount="50" kWh="3254.68" charge="55.84111773820851">
  <broker>Sample</broker>
  <postedTime>
    <iMillis>1256436000000</iMillis>
  </postedTime>
  <customerInfo>433</customerInfo>
  <tariffSpec>300000388</tariffSpec>
</tariff-tx>

and

<tariff-tx id="2403" txType="CONSUME" customerCount="3" kWh="-2.095" charge="0.26942463859380356">
  <broker>Sample</broker>
  <postedTime>
    <iMillis>1256436000000</iMillis>
  </postedTime>
  <customerInfo>474</customerInfo>
  <tariffSpec>300000390</tariffSpec>
</tariff-tx>

Unless I'm mistaken the broker must pay for production of its customers and the charge for production should be negative. If the sign of the charge is flipped for production when the cash is updated, though, then this will not be  a problem. However, when I look at the code, it seems this is not the case. The following code is from the AccountingService class in org.powertac.accounting and shows the processTransaction() method.

  // process a tariff transaction
  public void processTransaction(TariffTransaction tx,
                                 ArrayList messages) {
    //log.info("processing tariff tx " + tx.toString());
    updateCash(tx.getBroker(), tx.getCharge());
    // update the distribution report
    if (TariffTransaction.Type.CONSUME == tx.getTxType())
      distributionReport.addConsumption(-tx.getKWh());
    else if (TariffTransaction.Type.PRODUCE == tx.getTxType())
      distributionReport.addProduction(tx.getKWh());
  }

Unlike the sign of tx.getKWh() for the distribution report, the sign of tx.getCharge() is not flipped for the cash update. This seems to be contradictory with the tariff transactions' charges that are positive for both production and consumptions.

Could somebody please take a look at this? Thanks in advance.

Jasper

Reply | Threaded
Open this post in threaded view
|

Re: Charge for production

grampajohn
Administrator
Jasper wrote
I noted something in the source code of the server that I don't understand. When I look in the broker.trace file of the sample broker I see that the charges for both consumption and production are positive. ...
Thanks for spotting this. It is issue #517, now solved, but currently the solution is available only in the "controllable-capacity" branch of common. The problem was that one sign conversion was missed. I'm surprised we went this long before someone spotted it (you are the second person to spot it, to my knowledge).

We hope to have this branch merged back to master in another day or two. There are two small items left to finish up before it's all consistent.

Cheers -

John