0
$\begingroup$

I'm trying to plot the feasible region of a maximization problem with PlotRegion3D. This region is the intersection of two constraints and I'd like to plot also the line that goes through the points in which both constraints are satisfied as equalities. My end goal is to have this feasible region embedded in a Manipulate environment and, therefore, my current approach of computing the line manually is not adequate.

My code is

ClearAll["Global`*"]
X = {{1, 4}, {2, 4}, {4, 4}};
qVec = Array[q, 3];
kVec = {10, 15};
a = 1/2;
needs = Transpose[X].qVec^(1/a);
max = Table[(Min[kVec[[1]]/X[[i, 1]],kVec[[2]]/X[[i, 2]]])^a,{i, 1, 3}];
r1 = RegionPlot3D[needs[[1]] <= kVec[[1]] && needs[[2]] <= kVec[[2]], {q[1], 0, 
max[[1]]}, {q[2], 0, max[[2]]}, {q[3], 0, max[[3]]}, Mesh -> None];
inter = ParametricPlot3D[{(2 z^2 - 5/2)^a, (25/4 - 3 z^2)^a,z}, {z, Sqrt[5/4], Sqrt[25/12]}];
Show[{r1, inter}]

Ideally, I'd use the output of Solve[Flatten[{needs == kVec, Thread[qVec >= 0]}], qVec, Reals] in the ParametricPlot3D.

Also, feel free to suggest improvements in the code.

$\endgroup$

1 Answer 1

1
$\begingroup$

You're almost there:

inter = ParametricPlot3D[
   qVec /.
     Solve[Flatten[{needs == kVec, Thread[qVec >= 0]}], Rest@qVec, 
      Reals] // Evaluate,
   {q[1], 0, max[[1]]}
   ];
Show[{r1, inter}]

enter image description here

This simply solves for q[2] and q[3] as a function of q[1] (notice the Rest in the argument to Solve), and uses the result to parametrize qVec with q[1], which is then plotted.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.