Need some maths help figuring out calculations for Economy 7 electricity tariff

I'm no computer scientist but I'd have thought something using Newton-Raphson would work.

Otherwise I'm sure there are solvable simultaneous equations there which if it wasn't 11pm I could write down.

edit:

720*x + A*y + B*z = 600

(A + 720)/45 = B/55

where prices are x y & z.

Solve by substitution and you get your answer.

Wow, thanks! I'm not quite sure how I'll represent this in code, but I'll have a play around with it. Much appreciated. :)
 
Wow, thanks! I'm not quite sure how I'll represent this in code, but I'll have a play around with it. Much appreciated. :)

See if this works. I've probably made a mistake somewhere.

solvesime.png


edit:

Yep I can see a mistake.

rho = daytime %.
 
Last edited:
Looks like out of contract prices, i do think people are over complicating this, post up the cyarge period and the kwh used as shown on the bill please
 
Funny that we all did this at school to prepare for the adult world, yet now we are all in the adult world, nobody really knows what to do :D
 
--edit-- used wrong figure for Tier 1

I don't think it can be done with the info you have.

Tier 1 is known, so we can say 720kWh cost £186.2496
We then know that Tier 2 + Tier 3 cost £413.7504 which looks like:

0.17661x + 0.06123y = £413.7504

where x is kWh used on Tier 2 and y is kWh used on Tier 3. There are multiple solutions here so I don't think it can be worked out.

Although there could be only one solution that arrives at 555.9144 using only integers for x and y...
 
Last edited:
See if this works. I've probably made a mistake somewhere.

edit:

Yep I can see a mistake.

rho = daytime %.

Holy crap, thanks! I think I'm gonna have to try and digest this and let you know what I get.

Looks like out of contract prices, i do think people are over complicating this, post up the cyarge period and the kwh used as shown on the bill please

These are the results that uSwitch have calculated, based on paying £50 per month:

From the information you've given us we have estimated you'll use 4865 kWh in a year

The first 720 kWh of daytime usage will be charged at 25.868p per kWh: £186.25

The next 1469 kWh of daytime usage will be charged at 17.661p per kWh: £259.44

The remaining 2676 kWh will be charged at 6.123p per kWh: £163.85

Discount (I can ignore this for now): 1.78p/kWh off tier 2 rates for Economy 7 customers paying by Monthly Direct Debit up to a maximum of £38.09 a year

VAT: £28.57

Total: £600.02

However the numbers are slightly off because they're also applying a discount of 1.78p/kWh up to £38.09 on the 2nd tier.
 
Step away from uswitch and other comparison sites, they are less than useless and you'll end up paying through the rough.
They cant calculate tariffs other than tariffs with one single rate, as well as applying discounts you may not get.

If you know how much you use, make a spreadhseet yourself, yes its more work, but its worth it.
 
Step away from uswitch and other comparison sites, they are less than useless and you'll end up paying through the rough.
They cant calculate tariffs other than tariffs with one single rate, as well as applying discounts you may not get.

If you know how much you use, make a spreadhseet yourself, yes its more work, but its worth it.

Sorry, this isn't for calculating my own bill or anything. I need to write a calculation engine that will calculate usage, spend, etc. based on user inputs. So basically it needs to do exactly what uSwitch is doing. And because OfGem verify the results against sites like uSwitch, it needs to match.
 
Think I've done it, including the discount for DD payment. I couldn't get it to work until i realised that VAT is only 5% on electricity.....

Fill in all the green cells and then press the "Calculate Usage" button.

You'll have to enable macros to use the button, or you can just goal seek manually.

If you do it manually you need to Goal Seek

Set Cell : E29
To Value : Whatever is in C2
By changing cell : C32

That gives you the exact numbers created by USwitch.

https://dl.dropboxusercontent.com/u/47824599/Elec Calc.xlsm
 
Think I've done it, including the discount for DD payment. I couldn't get it to work until i realised that VAT is only 5% on electricity.....

Fill in all the green cells and then press the "Calculate Usage" button.

You'll have to enable macros to use the button, or you can just goal seek manually.

If you do it manually you need to Goal Seek

Set Cell : E29
To Value : Whatever is in C2
By changing cell : C32

That gives you the exact numbers created by USwitch.

https://dl.dropboxusercontent.com/u/47824599/Elec Calc.xlsm

You're amazing! :D It might still be a little bit of a challenge turning that in to code, but it looks like all the necessary calculations are there. Very much appreciated! :)
 
No probs!

What are you writing the code in, as long as there is some sort of goal seek function you can use / write or nick from somewhere then it should be fairly straightforward.
 
I've written the code in VBA, it runs really quickly so can you adapt this to c#?

Code:
Sub FindUseage()


wsTargetCost = Range("c2").Value
wsDayUsePerc = Range("c4").Value
wsNightUsePerc = 1 - Range("c4").Value
wsDayTier1Thresh = Range("c8").Value
wsTier2DiscRate = Range("c10").Value
wsTier2MaxDis = Range("c12").Value
wsDayTier1Rate = Range("c21").Value
wsDayTier2Rate = Range("c23").Value
wsNightRate = Range("c25").Value

wsGuess = 0
wsFineTune = 1

Do

    wsGuess = wsGuess + 1 / wsFineTune
    
    wsDayUseUnits = wsGuess * wsDayUsePerc
    wsNightUseUnits = wsGuess * wsNightUsePerc
    
    wsDayTier1Units = WorksheetFunction.Min(wsDayTier1Thresh, wsDayUseUnits)
    wsDayTier2Units = WorksheetFunction.Max(wsDayUseUnits - wsDayTier1Units, 0)
    
    
    wsDayTier1Cost = wsDayTier1Units * wsDayTier1Rate / 100
    wsDayTier2Cost = wsDayTier2Units * wsDayTier2Rate / 100
    wsNightCost = wsNightUseUnits * wsNightRate / 100
    wsDiscount = WorksheetFunction.Max(wsDayTier2Units * wsTier2DiscRate / 100, wsTier2MaxDis)
    
    wsCalcedCost = (wsDayTier1Cost + wsDayTier2Cost + wsNightCost - wsDiscount) * 1.05
    
    If Round(wsCalcedCost, 2) < Round(wsTargetCost, 2) Then
    
        wsLowLimit = wsGuess
    
    Else
    
        If Round(wsCalcedCost, 2) > Round(wsTargetCost, 2) Then
        
            wsHighLimit = wsGuess
            wsFineTune = 10
            wsGuess = wsLowLimit
        
        Else
        
            wsResult = wsGuess
            Exit Do
        
        End If
    
    End If
    
Loop

Range("C32").Value = wsGuess




End Sub
 
Wow, thanks! A couple of questions though. What values are you initially assigning to wsLowLimit and wsHighLimit? And should wsResult be used anywhere?

Edit: nevermind, I think I've figured it out. It's still not quite returning the right results, but it's not too far off. I'll keep tinkering with it. :)
 
Last edited:
Back
Top Bottom