Reformulating a simple cost function - combining 2 variables

In summary, the original equation for the cost of energy for a house per hour can be rewritten using variables Eext and Ebatt, where Eext represents the energy consumed and Ebatt represents the energy stored in the battery. The equation can also be written in terms of the new variable "energy" which is positive when energy is discharged and negative when it is charged. This can be done by using cases in the definition of the function.
  • #1
bradyj7
122
0
Hi there,

I have an equation below for the cost of energy for a house per hour. The house has an energy storage system (i.e.a very large battery) installed. You can charge the battery up and energy from the battery can be used to power the building. For example you can charge the battery when electricity prices are low and then you can use the energy in the battery to supply energy to the building when electricity prices are high so that the building does not have to purchase electricity at expensive times.

The equation is written in terms of the price of electricity, the energy consumed, efficiency constant and the variables energy_in and energy_out of the battery.

c(t) = Price(t) * (Energy_consumed(t) - eff*Energy_out + (1/eff)*Energy_out)

In a single hour energy can only enter of or be discharged from the battery. Therefore, when energy_in is positive, energy_out will always be zero and vice versa. You'll notice that this equation is written in terms of energy_in and energy_out, both variables can only be positive.

My question is as follows: I'd like to reformulate the equation to be only written in terms of the variable "energy" instead of as it is currently with energy_in and nergy_out. The new variable will be >0 when energy is discharged (out) and <0 when it is charged (in).

I was hoping if somebody could tell me if this possible?

Thank you for reading this.

Sincerely
 
Mathematics news on Phys.org
  • #2
bradyj7 said:
Hi there,

I have an equation below for the cost of energy for a house per hour. The house has an energy storage system (i.e.a very large battery) installed. You can charge the battery up and energy from the battery can be used to power the building. For example you can charge the battery when electricity prices are low and then you can use the energy in the battery to supply energy to the building when electricity prices are high so that the building does not have to purchase electricity at expensive times.

The equation is written in terms of the price of electricity, the energy consumed, efficiency constant and the variables energy_in and energy_out of the battery.

c(t) = Price(t) * (Energy_consumed(t) - eff*Energy_out + (1/eff)*Energy_out)

In a single hour energy can only enter of or be discharged from the battery. Therefore, when energy_in is positive, energy_out will always be zero and vice versa. You'll notice that this equation is written in terms of energy_in and energy_out, both variables can only be positive.

My question is as follows: I'd like to reformulate the equation to be only written in terms of the variable "energy" instead of as it is currently with energy_in and energy_out. The new variable will be >0 when energy is discharged (out) and <0 when it is charged (in).

I was hoping if somebody could tell me if this possible?
Sure, you can write the definition of the function using cases.
$$c(t) = \begin{cases} \text{Price(t)} * (\text{E}_{\text{ext}}(t) -\text{eff} * \text{E}_{\text{batt}}) & \text{if E}_{\text{batt}} \ge 0 \\
\text{Price(t)} * (\text{E}_{\text{ext}}(t) + \frac 1 {\text{eff}} * \text{E}_{\text{batt}}) & \text{if E}_{\text{batt}} \lt 0 \end{cases}$$

For the sake of simplifying the equation, I replaced Energy_consumed by Eext, and Energy by Ebatt.
 

1. What is a cost function?

A cost function is a mathematical function that measures the error or deviation between the predicted values and the actual values in a machine learning or optimization problem. It helps in finding the optimal values for the parameters in a model.

2. How do you combine 2 variables in a cost function?

To combine 2 variables in a cost function, you can use different techniques such as adding, subtracting, multiplying, or dividing the variables. You can also use more complex functions such as logarithms or exponents to combine the variables.

3. Why would you need to reformulate a simple cost function?

Reformulating a simple cost function can help improve the performance of a model. It can also help in addressing issues such as overfitting or underfitting, by adjusting the weights assigned to each variable in the cost function.

4. What are the benefits of combining 2 variables in a cost function?

Combining 2 variables in a cost function can lead to a more accurate and efficient model. It can also help in reducing the complexity of the cost function and improve the interpretability of the results.

5. Are there any limitations to reformulating a simple cost function?

Yes, there can be limitations to reformulating a simple cost function. It can be challenging to find the right combination of variables that will result in a better performing model. Also, the addition of more variables can increase the complexity of the cost function and make it more difficult to interpret the results.

Similar threads

Replies
4
Views
3K
Replies
1
Views
820
  • Thermodynamics
Replies
8
Views
822
  • DIY Projects
Replies
28
Views
2K
  • Thermodynamics
Replies
4
Views
1K
Replies
8
Views
874
  • Introductory Physics Homework Help
Replies
4
Views
2K
  • Programming and Computer Science
Replies
31
Views
2K
Replies
1
Views
1K
  • Electrical Engineering
3
Replies
75
Views
7K
Back
Top