0
$\begingroup$

I have this minimization program and although I've restricted my variables to be non negative, I get a nrnum error in the NMinimize step. I'm guessing this is what is causing the misaligned yellowish point in the plot (the other ones seem to be right, although it's hard to tell).

ClearAll["Global`*"]
A = {{1, 4}, {2, 2}, {4, 1}};
qVec = Array[q, 3];
onesVec = ConstantArray[1, 3];
optimalweights = 
  Table[Table[qVec /. NMinimize[{qVec^(1/a).A.{surf, 1 - surf}, 
    qVec.onesVec == 1, Thread[1 >= qVec >= 0]}, qVec, 
   Reals][[2]], {surf, 0, 1, 1/10}], {a, {1/2, 2/3}}];
ListPointPlot3D[optimalweights, ViewPoint -> {100, 100, 100} , 
  Axes -> None, Boxed -> False, BoxRatios -> {1, 1, 1}]

Also, Initially I used Minimize and it worked fine for the a=1/2 case. When I tried it with a=2/3 I ended up aborting the evaluation after it had ran for over 24 hours without producing an output.

$\endgroup$
6
  • 1
    $\begingroup$ Remove Realsinside NMinimize! $\endgroup$ Mar 31 at 12:34
  • $\begingroup$ @UlrichNeumann I removed it, but the problem persists $\endgroup$
    – Patricio
    Mar 31 at 12:58
  • $\begingroup$ Your code works on v12.2 . Perhaps you should restart your Mtahematica session? $\endgroup$ Mar 31 at 13:06
  • $\begingroup$ @UlrichNeumann I'm using v11.3. Perhaps is high time I update. Any idea about why Minimize takes so long? $\endgroup$
    – Patricio
    Mar 31 at 13:25
  • $\begingroup$ optimalweights is computed in 0.049824 sec. for me (Mac M1, V13.0.1). $\endgroup$
    – Michael E2
    Mar 31 at 14:37

1 Answer 1

2
$\begingroup$

After removing Reals inside NMinimize your code evaluates

ClearAll["Global`*"]
A = {{1, 4}, {2, 2}, {4, 1}};
qVec = Array[q, 3];
onesVec = ConstantArray[1, 3];
optimalweights = 
  Table[Table[qVec /. NMinimize[{qVec^(1/a).A.{surf, 1 - surf}, 
    qVec.onesVec == 1, Thread[1 >= qVec >= 0]}, qVec, 
   Reals][[2]], {surf, 0, 1, 1/10}], {a, {1/2, 2/3}}];
ListPointPlot3D[optimalweights, ViewPoint -> {100, 100, 100} , 
  Axes -> None, Boxed -> False, BoxRatios -> {1, 1, 1}]

enter image description here

$\endgroup$

Your Answer

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

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