a =sdpvar(1,m);
b =sdpvar(1,m);
c =sdpvar(1,m);
t =sdpvar(1,m);
Objective = sum(t.*(b+c));
Constraints = [t*sum(d + a) == d+a];
m = 3;
b =sdpvar(1,m);
c =sdpvar(1,m);
t =sdpvar(1,m);
t.*(b+c) - (b+c).*t
Sdpvar a b c t x are all (1,m) vectors.
d, f, g, (1,m) , three known vectors.
t =(a+d)/sum(a+d) which is described in constraint : t* sum(a+d) = = (a+d),sum(t)==1
objective=sum( ( b+sum(c) ).*t ) ,ok
objective=sum(t .* ( b+sum(c) ) ) , with the error:
??? Error using ==> sdpvar.times at 190
m = 3;
a = sdpvar(1,m);
b = sdpvar(1,m);
t = sdpvar(1,m);
x = sdpvar(1,m);
c = max( b+x.*f,g)
% Works
objective=sum((b+sum(c)).*t)
% fails
objective=sum(t.*(b+sum(c)))
m = 3;
a = sdpvar(1,m);
b = sdpvar(1,m);
c = sdpvar(1,m);
t = sdpvar(1,m);
x = sdpvar(1,m);
Constraints = [c == max( b+x.*f,g)]
% Works
objective=sum((b+sum(c)).*t)
% Works
objective=sum(t.*(b+sum(c)))
m=3
a=sdpvar(1,m)
b=sdpvar(1,m)
c=sdpvar(1,m)
t=sdpvar(1,m)
x=sdpvar(1,m)
e=sdpvar(1,m)
for i=1:m
c(i)=max( b(i)+x(i)*f(1), g(1));
for j=1:n
c(i)= c(i)+max( b(i)+x(i)*f(j), g(j));
end
e(i)=b(i)+c(i)/n
end
objective=e.*t; % works
objective=t.*e; % fails
your given example“ it is a very different model, although it describes the same relationships”. that is the question what I have, too. I wonder if it’s ok to talk about it here or open another topic.
These are two descriptions in my program:
constraints=[t*sum(a+d) == (a+d)]; % works
t=(a+d)/sum(a+d) ; fails,
“Sigmonial scalar”
What does that means? And how the two descriptions work so different? which one should i use?
for i=1:m
c(i) = max( b(i)+x(i)*f(1), g(1));
for j=2:n
c(i) = c(i)+max( b(i)+x(i)*f(j), g(j));
end
end
for i=1:m
c(i) = sum(max([b(i) + x(i)*f;g],[],1));
end
s = 0;
e = [];
for i = 1:m
...
s = [s;s(i)+a(i)+h(i)];
...
e = [e;b(i)+c(i)/n];
end
f1=[1119 1274 1198 924 1274];
f2=[800 400 400 800 800];
g=[0 1 2 3 4];
d=[1477 1389 1323];
h=[0.51 1.02 0.51];
P=0;
s=640;
constraints=[0<=x1(:)<=1,0<=x2(:)<=1];
for i=1:3
c(i)=sum(max([b(i)+x1(i)*f1+x2(i)*f2;g],[],1));
s=[s;s(i)+a(i)*0.8+h(i)];
a_up=160-h(i)*0.5;
r=x1(i)*1119+x2(i)*800-a(i)-d(i);
p=x1(i)*0.8+x2;
p_up=(d(i)+a(i))*0.9;
r_up=(d(i)+a(i))*0.3;
P=P+p;
constraits=[constraints,0<=a(i)<=a_up,0<=p<=p_up,0<=r<=r_up];
e(i)=b(i)+c(i)/5;
end
constraints=[constraints,P<300,sum(a)==sum(h)*0.8,128<=s(:)<=640,sum(t)==1,t*sum(a+d)==(a+d)];
objective= - sum(e.*t)
sol = solvesdp(constraints,objective);
if sol.problem == 0
a=double(a)
b=double(b)
x1=double(x1)
x2=double(x2)
else
display('Hmm, something went wrong!');
end
constraints=[constraints,P<300,sum(a)==sum(h)*0.8,128<=s(:)<=640,sum(t)==1,t*sum(h)*.8+t*sum(d)==(a+d)];