How do I create a pair of matrices approximating a convex hull of a set of points in 2-space?
이전 댓글 표시
I am trying to approximate the convex hull of payoffs for a 2x2 normal form game. The inputs would be the four points defining the payoffs at each of the four pure strategy outcomes, plus a factor k that would define the increments (and matrix sizes) of the approximating Row and Column player payoffs of the convex hull of payoffs. (So if k=10, the outputs would be a pair of 11x11 matrices UR and UC where UR has the convex hull payoffs for Row at 1/10 increments and UC has the convex hull of payoffs for Column at 10 point increments.)
My motivating problem is I'm trying to analyze an discretized approximation of a 2-playey bargaining problem that's constructed by creating the convex hull of payoffs for a 2x2 coordination game.
댓글 수: 8
Image Analyst
2014년 6월 7일
I've never heard of convex hull in that context. Can you give some numerical example? And show why convhull() cannot be used to solve your problem.
Peter Vanderschraaf
2014년 6월 9일
Peter Vanderschraaf
2014년 6월 9일
Here's what I would do. Express the point as the intersection of two lines going each from opposite segments of the unit square (make them orthogonal to those segments to make it simpler). Compute where those two lines intersect the unit square (really easy if they are orthogonal to said segments).
Express that as a fraction of segment length.
Project those four intersections to the new coordinates. Get the equation for those 2 new lines. The point you want would be the intersection of those two new lines.
Peter Vanderschraaf
2014년 6월 10일
@Peter
The mapping you describe is not unique, in general. Consider, for example, the special case of the mapping of the unit square into itself. One obvious candidate is
u(x,y)=[x,y]
Another is
u(x,y)=[y,x]
Yet another is the 90 rotation of the unit square about its center. There are infinite possibilities. You need more criteria.
It is also possible that the mapping is nonlinear. For example, there is no linear/affine mapping that satisfies
(0,0) maps to (0,0)
(0,1) maps to (0,1)
(1,0) maps to (1,0)
(1,1) maps to (2,2)
José-Luis
2014년 6월 10일
I assumed a linear mapping. If non-affine transforms come into play, funny things can start to happen.
답변 (2개)
Assuming linear mapping:
Not the most efficient thing out there, but it serves as a proof of concept. The important thing is that your vertices must be ordered either clockwise or counterclockwise:
%You need to provide ordered vertices either clockwise or counterclockwise
unit_square = [0,0;...
0,1;...
1,1;...
1,0];
mapped_poly = [2,1;...
7,3;...
4,10;...
1,2];
unit_square = [unit_square;unit_square(1,:)];
mapped_poly = [mapped_poly;mapped_poly(1,:)];
patch(unit_square(:,1),unit_square(:,2),'r','FaceAlpha',0.5);
hold on;
patch(mapped_poly(:,1),mapped_poly(:,2),'g','FaceAlpha',0.5);
point_to_project = rand(1,2);
x = point_to_project(1);
y = point_to_project(2);
plot(x,y,'ks');
bottom_position = mapped_poly(1,:) + x .* (mapped_poly(2,:) - mapped_poly(1,:));
right_position = mapped_poly(2,:) + y .* (mapped_poly(3,:) - mapped_poly(2,:));
top_position = mapped_poly(3,:) + (1 - x) .* (mapped_poly(4,:) - mapped_poly(3,:));
left_position = mapped_poly(4,:) + (1 - y) .* (mapped_poly(1,:) - mapped_poly(4,:));
%fit linear polynomial
p1 = polyfit([bottom_position(1) top_position(1)] ,[bottom_position(2) top_position(2)],1);
p2 = polyfit([left_position(1) right_position(1)] ,[left_position(2) right_position(2)],1);
%calculate intersection
x_intersect = fzero(@(x) polyval(p1-p2,x),3);
y_intersect = polyval(p1,x_intersect);
plot(x_intersect,y_intersect,'ks');
If the mapping is a known linear/affine one, u=A*x+b, then you can do
T=[A,b;[0 0 1]];
[x,y]=ndgrid(linspace(0,1,10));
pre=[x(:),y(:)].';
pre(end+1,:)=1;
u=T*pre;
ux=u(1,:);
uy=u(2,:);
scatter(ux,uy)
카테고리
도움말 센터 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!