0
$\begingroup$

I want to find maximum of convexhull area for n points. I try to give a small example (n=4) as follow

<< ComputationalGeometry`
NMaximize[{ConvexHullArea[{{xx1, yy1}, {xx2, yy2}, {xx3, yy3}, {xx4, 
     yy4}}], -0.5 <= xx1 <= 0.5, -0.5 <= xx2 <= 0.5, -0.5 <= xx3 <= 
   0.5, -0.5 <= xx4 <= 0.5, -0.5 <= yy1 <= 0.5, -0.5 <= yy2 <= 
   0.5, -0.5 <= yy3 <= 0.5, -0.5 <= yy4 <= 0.5}, {xx1, xx2, xx3, xx4, 
  yy1, yy2, yy3, yy4}]

the result show that

{1., {xx1 -> -0.5, xx2 -> 0.5, xx3 -> -0.5, xx4 -> 0.5, yy1 -> 0.5, 
  yy2 -> 0.5, yy3 -> -0.5, yy4 -> -0.5}}

But if I change to array like

A2 = Array[x2, 4];
B2 = Array[y2, 4];
C2 = Join[{A2, B2}, 2];
c3 = Table[-0.5 < x2[i] < 0.5, {i, 1, 4}];
c4 = Table[-0.5 < y2[i] < 0.5, {i, 1, 4}];

and find the maximum

NMaximize[{ConvexHullArea[Transpose[C2]], c3, c4}, C2]

I got some error like this

NMaximize::lvar: Variables {{x2[1],x2[2],x2[3],x2[4]},{y2[1],y2[2],y2[3],y2[4]}} should be a list of variables, with each element being a variable, or a list containing a variable and lower and upper bounds for the starting region for that variable. >>

How should I do?

$\endgroup$
  • $\begingroup$ ConvexHullArea is undefined. Apart from that, I suggest to try NMaximize[Evaluate[{ConvexHullArea[Transpose[C2]], c3, c4}], Evaluate[C2]]. $\endgroup$ – Henrik Schumacher Jan 8 at 17:51
  • $\begingroup$ It gives error in the same. I forgot to tell you that we have to import << ComputationalGeometry` before running ConvexHullArea. However, they are the same error. $\endgroup$ – Num Jan 8 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.