This is more like an **optimization problem** but any solution is appreciated.

I have a data set with input specifying **power(demand)** to be generated for a particular **time period(TP)**.

**Input**:

**Time --- Power**

01 to 02 1000

02 to 03 2000

03 to 04 2000

04 to 05 1500

etc.,

But the power can't just be increased from **1000 to 2000 at 01:59:59**.
Here there will be some ramping rate(gradient) which I want to **minimise** by keeping the imbalance to 0. Imbalance may arise if you deviate from what is needed, here power cannot be more or less than what is required in that Time Period.

In summary I have to generate the **black line(which is output)** below **(red line is the input)**.

I am trying to get an output which can be a curve(black line) equation or the power to generate at the deflection points(say at around 1:45 we generate 800 then at 2:15 it can be 2200 which will keep the imbalance to 0).

When I tried to treat this as an optimization problem it may look something like this:

**Objective** : `Minimise gradient f(x) = Yj-Yi/Xj-Xi`

between 2 points `(Xi,Yi)`

and `(Xj,Yj)`

**Subject to constraints**:

```
average of Yi = Power value(redline in that Time Period)
```

But I am struggling to complete it how to represent mathematically to be able to implement using programming like R's lpsolve/optimize or Python's scipy optimizers.

Any help on the approach to take would be greatly appreciated.

`MCNN`

and why is the value`1000 MWh`

written in red cut with a line, only to be rewritten below in black? Did you mean, say,`800 MWh`

? – Alex M. May 15 at 12:17