The problem formulation for which I need optimization is as follow:
D- BUYER AGENT
S-SELLER AGENT
p-price
pj โ€“ price per unit
aj- amount of energy available
gj- total generation energy
ui- buyer utilities
vj- seller utilities
bi - bid of each buyer
maximize w.r.t ๐‘‘๐‘–, ๐‘ ๐‘—,
๐›ฉ(๐‘‘๐‘–, ๐‘ ๐‘—)=ฮฃ๐‘ข ๐‘–(๐‘‘๐‘–) +ฮฃ๐‘ฃ๐‘—(๐‘”๐‘— โˆ’ ๐‘ ๐‘—)
๐‘–โˆˆ๐’Ÿ ๐‘—โˆˆ๐’ฎ
subject to,
๐‘‘๐‘– โ‰ค ๐‘๐‘–; โˆ€๐‘– โˆˆ ๐’Ÿ
๐‘ ๐‘— โ‰ค ๐‘Ž๐‘—; โˆ€๐‘— โˆˆ ๐’ฎ
ฮฃ๐‘‘๐‘– =ฮฃ๐‘ ๐‘—
๐‘–โˆˆ๐’Ÿ ๐‘—โˆˆ๐’ฎ
Auction happens in iterative manner

 ์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Torsten
Torsten 2022๋…„ 10์›” 27์ผ
ํŽธ์ง‘: Torsten 2022๋…„ 10์›” 27์ผ

1 ๊ฐœ ์ถ”์ฒœ

  1. Put your unknowns in a vector x.
  2. Write your function to be maximized as f*x where f is to be determined from your above problem formulation.
  3. Write your inequality constraints as A*x <= b where A and b are to be determined by your above problem formulation.
  4. Write your equality constraint as Aeq*x = beq where Aeq and beq is to be determined by your above problem formulation.
  5. Determine lower and upper bounds on your unknowns and put them in the arrays lb and ub.
  6. Call linprog.

๋Œ“๊ธ€ ์ˆ˜: 11

Jatinder Azrot
Jatinder Azrot 2022๋…„ 10์›” 31์ผ
Thanks for your response @Torsten, but as I'm new to MATLAB, can you please elaborate how to put unkowns in vectorx, and further steps also.
Thanks in advance
Torsten
Torsten 2022๋…„ 10์›” 31์ผ
ํŽธ์ง‘: Torsten 2022๋…„ 10์›” 31์ผ
So let's try linprog for your problem:
Start with the vector of unknowns. These are d1,...,dD,s1,...,sS.
Since you want to maximize theta, you want to minimize -theta.
So your vector f that has to be passed to linprog is
f = [-u,v]
where u and v are vectors of length D and S, respectively (buyer and seller utilities).
Now your first and second constraints are bound constraints that have to be defined with the help of lb and ub:
lb = [zeros(size(u)),zeros(size(v))]
ub = [b,a];
a = amount of energy available, b = bid of each buyer.
The third constraint has to be put in Aeq and beq:
Aeq = [ones(size(u)),-ones(size(v))];
beq = 0;
Now you can call linprog:
sol = linprog(f,[],[],Aeq,beq,lb,ub)
That's all.
Of course, you must give values to the vectors a, b, u and v first.
Jatinder Azrot
Jatinder Azrot 2022๋…„ 11์›” 8์ผ
Thanks a lot @Torsten, can I assign the values to a,b,u and v like:
u = randperm(5,1);
v = randperm(4,1);
a = randperm(50,1);
b = randperm (30,1);
and do I not need to mention g and s
Torsten
Torsten 2022๋…„ 11์›” 8์ผ
You want u,v,a,b to have one single element ?
Jatinder Azrot
Jatinder Azrot 2022๋…„ 11์›” 8์ผ
I want them to have a range of values
Torsten
Torsten 2022๋…„ 11์›” 8์ผ
rng('default')
u = rand(1,6);
b = rand(1,6);
v = rand(1,9);
a = rand(1,9);
f = [-u,v];
lb = [zeros(size(u)),zeros(size(v))];
ub = [b,a];
Aeq = [ones(size(u)),-ones(size(v))];
beq = 0;
sol = linprog(f,[],[],Aeq,beq,lb,ub)
Optimal solution found.
sol = 15ร—1
0.2785 0.5469 0 0.9649 0.1576 0 0 0.5114 0 0.6787
Jatinder Azrot
Jatinder Azrot 2022๋…„ 11์›” 9์ผ
Thank you @Torsten, I wanted to ask you one more thing, I'm working on NSGA II and I've two function and defined functions like below, is it correct or I need to do as you described earlier:
function z = MOP41(x)
u = randperm(5,1); % buyer utility
d = randperm(10,1); %amount of energy delevered to each buyer
c = randperm(4,1); % seller utility
s = randperm(15,1); % amount of energy each seller can deliver
g = randperm(30,1); % total energy generated
a = randperm(50,1);
b = randperm (30,1);
s1 = 0;
s2 = u*d;
s3 = 0;
s4 = c*(g-s);
n= 7;
for i=1:n
s1= s1+ s2;
end
for i= 1:n
s3 = s3+s4;
end
d<=b;
s<= a;
% Edit the lines below with your calculations.
benergy=randperm(50,1);
bhighest= randperm(40,1);
d=randperm(30,1);
t=5;
g=randperm(20,1);
T = 7;
K= 100;
I= 50;
for i=1:K
d=d;
end
for i= 1:I
g=g;
end
g<d;
for i= 1:T
x = d-g;
end
y= x*t*benergy;
y<= pi;
bhighest < benergy;
% Edit the lines below with your calculations.
%objective = b* log(d) - z;
% objective = max (objective);
%F(1) = s1 + s3;
%F(2) = x*t*benergy;
%x = optimInput(1);
%y = optimInput(2);
%end
z1 = s1 + s3;
z2 = x*t*benergy;
z = [z1 z2]';
end
Torsten
Torsten 2022๋…„ 11์›” 9์ผ
ํŽธ์ง‘: Torsten 2022๋…„ 11์›” 9์ผ
I gave you the code to solve the optimization problem you posted.
I'm completely lost what you try to do with the function from above since it is full of errors and settings I do not understand.
I suggest you first try to improve your MATLAB skills here
and then work through some examples for "linprog" included here
Jatinder Azrot
Jatinder Azrot 2022๋…„ 11์›” 10์ผ
Thanks for the help with the code, I'm sorry I was trying other objective function and by mistake posted that, but the code you gave did not mentioned 'g' and 's' in the function. you only mentioned funtion of u and v, so I wanted to ask will it effect anyway on the performance
Jatinder Azrot
Jatinder Azrot 2022๋…„ 11์›” 10์ผ
Also can you tell me is the below written code correct for the two objective function as mentioned below:
ist objective
min(g,d,benergy): ฮฃ(ฮฃ๐‘‘ - ฮฃ๐‘”) *t * benergy
subject to:
g<d, bhighest<benergy, ฮฃ(ฮฃ๐‘‘๐‘– - ฮฃ๐‘”๐‘—) *t * benergy <= pi
and 2nd objective
max(g,d,benergy): ฮฃ(ฮฃg - ฮฃd) *t * benergy - ฮฃcczrbon
subject to:
d<g, bhighest<benergy, 0<ccarbon<=pi
code for both objective function:
function z = MOP41(x)
benergy1 = randperm(50,1);
bhighest1 = randperm(40,1);
d1 = randperm (30,1);
g1 = randperm(20,1);
t1 = 5;
ccarbon = randperm(30,1);
Tseller = 7;
K1 = 100;
I1 = 50;
for i = 1:I1
g1=g1;
end
for i = 1:K1
d1 =d1;
end
for i=1:Tseller
u = g1-d1;
end
v= u*t1*bhighest1 + ccarbon;
d1 < g1;
bhighest1<benergy1;
0<ccarbon<pi;
% Edit the lines below with your calculations.
benergy=randperm(50,1);
bhighest= randperm(40,1);
d=randperm(30,1);
t=5;
g=randperm(20,1);
T = 7;
K= 100;
I= 50;
for i=1:K
d=d;
end
for i= 1:I
g=g;
end
g<d;
for i= 1:T
x = d-g;
end
y= x*t*benergy;
y<= pi;
bhighest < benergy;
z1 = (u*t1*bhighest1 + ccarbon);
z2 = x*t*benergy;
z = [z1 z2]';
end
Torsten
Torsten 2022๋…„ 11์›” 10์ผ
ํŽธ์ง‘: Torsten 2022๋…„ 11์›” 10์ผ
d = sol(1:numel(u))
and
s = sol(numel(u)+1:end)
They have to be put in one common solution vector "sol" for linprog to work.
sum(v.*g) is constant and does not need to appear in the objective function.
rng('default')
u = rand(1,6);
b = rand(1,6);
v = rand(1,9);
a = rand(1,9);
f = [-u,v];
lb = [zeros(size(u)),zeros(size(v))];
ub = [b,a];
Aeq = [ones(size(u)),-ones(size(v))];
beq = 0;
sol = linprog(f,[],[],Aeq,beq,lb,ub);
Optimal solution found.
d = sol(1:numel(u))
d = 6ร—1
0.2785 0.5469 0 0.9649 0.1576 0
s = sol(numel(u)+1:end)
s = 9ร—1
0 0.5114 0 0.6787 0.7577 0 0 0 0

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ Systems of Nonlinear Equations์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ

๋ฆด๋ฆฌ์Šค

R2022b

์งˆ๋ฌธ:

2022๋…„ 10์›” 27์ผ

ํŽธ์ง‘:

2022๋…„ 11์›” 10์ผ

Community Treasure Hunt

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

Start Hunting!

Translated by