restart:with(simplex):
obj:=x+y+z;
cnsts:={1-x-z<=0,1-y-z<=0,1-x-y<=0};
minimize(obj,cnsts,NONNEGATIVE);
assign(%);
obj;
restart:
with(simplex):
obj:=x1+x2+x3:
cnsts:={105-x1-x2<=0,120-x1-x3<=0,135-x2-x3<=0};
minimize(obj,cnsts,NONNEGATIVE);
assign(%);
obj;
restart:
with(simplex):
cnsts:={-x1<=z,-x2<=z,-x3<=z,2-x1-x2<=z,1-x2-x3<=z,-x1-x3<=z,x1+x2+x3=5/2};
minimize(z,cnsts);
restart:
cnsts:={-x1<=z,-x2<=z,-(5/2-x1-x2)<=z,2-x1-x2<=z,
1-x2-(5/2-x1-x2)<=z,-x1-(5/2-x1-x2)<=z};
Core:=subs(z=0,cnsts);
with(plots):
inequal(Core,x1=0..2,x2=0..3,optionsfeasible=(color=red), optionsopen=(color=blue,thickness=2),
optionsclosed=(color=green, thickness=3),
optionsexcluded=(color=yellow));
ECore:=subs(z=-1/4,cnsts);
inequal(ECore,x1=0..2,x2=0..3,optionsfeasible=(color=red),optionsopen=(color=blue,thickness=2),
optionsclosed=(color=green, thickness=3),
optionsexcluded=(color=yellow));
animate(inequal,[cnsts, x1=0..2,x2=0..3,
optionsfeasible=(color=red),
optionsopen=(color=blue,thickness=2),optionsclosed=(color=green,thickness=3),
optionsexcluded=(color=yellow)],
z=-1..0,frames=50);
restart:
with(simplex):
cnsts:={-x1<=z, -x2<=z,x2-3/5<=z, x1-4/5<=z,x1+x2=9/10};
minimize(z,cnsts);
restart:
with(simplex):v1:=0:v2:=0:v3:=0:v12:=1/3:v13:=1/6:v23:=5/6:v123:=1;
cnsts:={v1-x1<=z,v2-x2<=z,v3-x3<=z,v12-(x1+x2)<=z,
v13-(x1+x3)<=z,v23-(x2+x3)<=z,x1+x2+x3=v123};
minimize(z,cnsts);
fcnsts:=subs(z=-1/12,x1=1-x2-x3,cnsts);
gcnsts:=fcnsts[2..7];
with(SolveTools:-Inequality):
glc:=LinearMultivariateSystem(gcnsts,[x2,x3]);
assign(x1=1/12,z=-1/12);
cnsts1:={v1-x1<=z,v2-x2<=z,v3-x3<=z,v12-(x1+x2)<=z,
v13-(x1+x3)<=z,v23-(x2+x3)<=z,x1+x2+x3=v123};
cnsts2:={v2-x2<=z2,v3-x3<=z2,v12-(x1+x2)<=z2,
v13-(x1+x3)<=z2,x1+x2+x3=v123};
minimize(z2,cnsts2);
fcnsts2:=subs(z2=-7/24,11/12=x2+x3,cnsts2);
gcnsts2:=fcnsts2[2..5] union {x2+x3<=11/12,x2+x3>=11/12};
g1c2:=LinearMultivariateSystem(gcnsts2,[x2,x3]);
restart:with(simplex):v1:=0:v2:=0:v3:=0:
v12:=2:v13:=2:v23:=10:v123:=12;
with(SolveTools:-Inequality):
cnsts:={v1-x1<=z,v2-x2<=z,v3-x3<=z,v12-(x1+x2)<=z,
v13-(x1+x3)<=z,v23-(x2+x3)<=z,x1+x2+x3=v123};
minimize(z,cnsts);
fcnsts:=subs(z=-1,x3=12-x1-x2,cnsts);
gcnsts:=fcnsts[1..7] minus {fcnsts[2]};
Core1:=subs(z=0,x3=12-x1-x2,cnsts);
Core:=Core1 minus {Core1[1]};
with(plots):
inequal( Core,x1=0..12, x2=0..12,
optionsfeasible=(color=red),
optionsopen=(color=blue,thickness=2),
optionsclosed=(color=green, thickness=3),
optionsexcluded=(color=yellow),labels=[x1,x2] );
g1c:=LinearMultivariateSystem(gcnsts,[x1,x2]);
assign(x1=1,z=-1);
cnsts1:={v1-x1<=z,v2-x2<=z,v3-x3<=z,v12-(x1+x2)<=z,
v13-(x1+x3)<=z,v23-(x2+x3)<=z,x1+x2+x3=v123};
cnsts2:={v2-x2<=z2,v3-x3<=z2,v13-(x1+x3)<=z2,
v12-(x1+x2)<=z2,x1+x2+x3=v123};
minimize(z2,cnsts2);
fcnsts2:=subs(z2=-9/2,cnsts2);
gcnsts2:=fcnsts2[2..4] union {x2+x3<=11,x2+x3>=11};
g1c2:=LinearMultivariateSystem(gcnsts2,[x2,x3]);assign(x2=11-x3,z2=-9/2);
cnsts3:={v2-x2<=z2,v3-x3<=z2,v12-(x1+x2)<=z2,v13-(x1+x3)<=z2,x1+x2+x3=v123};
restart:
with(plots):with(plottools):with(LinearAlgebra):
A:=Matrix([[2,-1],[-1,1]]);B:=Matrix([[1,-1],[-1,2]]);
f:=(x,y)->expand(Transpose(<x,1-x>).A.<y,1-y>); expand(F(x,y));
g:=(x,y)->expand(Transpose(<x,1-x>).B.<y,1-y>);
points:={seq(seq([f(x,y),g(x,y)],x=0..1,0.05),y=0..1,0.05)}:
pure:=([[2,1],[-1,-1],[-1,-1],[1,2]]);
pp:=pointplot(points);
pq:=polygon(pure,color=yellow);
display(pq,pp,title="Payoffs with and without cooperation");
restart:
with(Optimization):
NLPSolve((u+13/4)*(v+5/2),{u>=-13/4,v>=-5/2,v<=-u+19},maximize);
restart:
f:=(x,y)->(x/2)*(ln(1+y));
cnst:={0<=x, x<=1000, 0 <=y, y<=1000, x+y <=1000};
with(Optimization):
NLPSolve(f(x,y),cnst,assume=nonnegative,maximize);
restart:
mypoints:=[[-1, -1], [-2, 2], [1, 1], [2, -2], [-1, -1]];
constr:={0 <=x,-3*x-y<=4, x+3*y<=4, 3*x+y<=4, -x-3*y<=4, 1<=y};
z:=(x+0)*(y-1);
iplot2:=plots[inequal](constr,x=-0.5..2, y=-0.5..2,
optionsfeasible=(color=white),
optionsclosed=(color=black, thickness=2),
optionsexcluded=(color=white),title="Feasible Set
with (0,1) security"):
pol:=plots[polygonplot](mypoints, color=yellow):
cp:=plots[contourplot](z, x=-2..3,y=-2..3,
contours=40, axes=boxed,thickness=2):
plots[display](iplot2, pol,cp);
with(Optimization):
NLPSolve(z,constr,maximize);