How to write equality constraints for receivers that hourly consume a certain amount of energy

1. How to write equality constraints for receivers that hourly consume a certain amount of energy (let's say 0.9 kWh) once a day? Its hourly consumption can be 0 or 0.9. Its total daily consumption = 0.9. I set lb = 0 and up = 0.9. During the optimization process, this consumption is flexible, the receiver can be scheduled to consume at 11 or 12 o'clock for instance.
2. How to write equality constraints for receivers that can't be interrupted and consume at two consecutive hours certain amount of energy (let's say 2 and 0.7 kWh) once a day? Its total daily consumption = 2.7. I set lb = 0 and ub = 2. This receiver can also consume at any time intervals, the only restrictions are: it should consume at two consecutive time intervals and first 2 kWh and then 0.7 kWh.

2 件のコメント

Brendan Hamm
Brendan Hamm 2015 年 8 月 12 日
What does the vector of design variables look like? Is it hourly consumption rates for the entire day? What is the length of the variable (24-by-1)?
Simona
Simona 2015 年 8 月 12 日
編集済み: Simona 2015 年 8 月 12 日
It is a 1x24 variable. Its hourly consumption = daily consumption, so it is on only for an hour. For other receivers (their hourly consumption forms variables), that consume entire day (such as refrigerator) I wrote Aeq(1,1:24) = [1,1,1,...x24], beq = 5, 5 means its daily consumption.

サインインしてコメントする。

 採用された回答

You should be representing the design variables as a column vector, I will call it x. With that in mind we want the constraint:
Aeq*x = beq;
If we wish to write the sum of values in x is equal to 5, then we should have:
Aeq = ones(1,24);
beq = 5;
Now simply pass these into the appropriate solver.
For part 2 you will likely need to use some form of global optimization for this, unless your objective in linear as is expected by intlinprog.

7 件のコメント

Simona
Simona 2015 年 8 月 12 日
I am afraid I was not clear enough. Let me explain. I already set x as variables' vector. x has 168 rows since I have 7 receivers multiplied by 24 hours. Then for each receiver I set lb and ub. I have no A and b. I only have Aeq and beq to set. These 7 receivers are different as in reality: refrigerator is on 24 hours a day, but washing machine is not. For refrigerator, it was easy to set Aeq = ones(1,24), but for washing machine I don't know how to set Aeq, because it should be on only one hour and this hour is flexible from the optimization point of view. It doesn't matter when washing machine is on, the point is to be on once a day. By Aeq and beq I just set daily consumption for each receiver.
Brendan Hamm
Brendan Hamm 2015 年 8 月 12 日
What is the function you are trying to minimize?
Simona
Simona 2015 年 8 月 12 日
編集済み: Simona 2015 年 8 月 12 日
min(hourly consumption * price). Price has two levels (0.1 at night and double otherwise)
Brendan Hamm
Brendan Hamm 2015 年 8 月 12 日
編集済み: Brendan Hamm 2015 年 8 月 12 日
If this is the case and the washing machine only has to be on for 1 hour you have as many solutions as you have daytime hours (and no real need for an optimization problem). If you really want to perform an optimization on this, then since this is a linear problem it would not be an issue (but again there are so many possibilities for the solution). We can use intlinprog and just rethink about how we want to setup the problem:
Our design vector x will just be an indicator of whether or not the washing machine is on during each hour. We need the constraint that there is only 1 hour it is on. For intlinprog we are minimizing f'x, so assuming the first 12 hours are night and the next 12 are day, f is:
f = [repmat(0.1,12,1); repmat(0.2,12,1)];
intcon = 1:24;
Aeq = ones(1,24);
beq = 1;
lb = zeros(24,1);
ub = ones(24,1);
[xVal,fMin] = intlinprog(f,intcon,[],[],Aeq,beq,lb,ub)
If you really need to combine this with the other optimization problems you can, but since it is linear then you robjective, min(hourly consumption * price), is the same as the sum of the minimums of each device separately.
Brendan Hamm
Brendan Hamm 2015 年 8 月 12 日
I forgot to mention that you can just multiple f by the usage for the washing machine in this problem as well.
Simona
Simona 2015 年 8 月 12 日
I will try this approach, that means to add new constraints related to on(1)/off(0) state to the existing ones. Thank you!
Simona
Simona 2015 年 8 月 13 日
When I used intcon for a couple of variables 145:168 Matlab ignored lb=zeros(168,1) and I don't know why. I am very curious. Then I put intcon for all variables and it worked well. Now, I want to change objective function and I don't know how to do this because the new function depends on the results. Objective function should be min(hourly consumption). Hourly consumption should be consumption of 1st receiver + consumption of 2nd receiver... at 1 o'clock and so on.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

質問済み:

2015 年 8 月 12 日

コメント済み:

2015 年 8 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by