2
$\begingroup$

I have two variables x1 and x2 and I use them to calculate 4 metrics y1,y2,y3, and y4. now I want to solve for the value of x1 and x2 so that these four metrics are as large as possible. Can anyone give me some hints? Any method or language is fine.

Subscript[y, 1] = Subscript[x, 1]
Subscript[y, 2] = 1/(1 + 1/Subscript[x, 2])
Subscript[y, 3] = (1 - 2*Subscript[x, 1])/(1 + Subscript[x, 2]) + 
  Subscript[x, 1]
Subscript[y, 4] = 2/((1 + 1/Subscript[x, 2]) + 1/Subscript[x, 1])

enter image description here

Boundaries:

0 < Subscript[x, 1] <=1
0 < Subscript[x, 2]
0 <= Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[y, 4] <= 1

enter image description here

$\endgroup$
8
  • $\begingroup$ Please post the Mathematica code,not the picture. $\endgroup$
    – cvgmt
    May 25 at 1:59
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. Please provide copy-paste-able code so that forum participants can experiment with it and assist you further. It is also a good idea to include details on what you have tried out so far. $\endgroup$
    – Syed
    May 25 at 2:23
  • $\begingroup$ This is my first time using Mathematica and I am not sure if my formula code is correct. $\endgroup$ May 25 at 2:33
  • 1
    $\begingroup$ "so that these four metrics are as large as possible"??? What if the first metric is very very good and the other three are bad? Or the first three are good and the last is very very bad? Can you edit your question to describe exactly what single expression you want to maximize? That expression will include y1,y2,y3,y4 in some form. Given that expression people can try to maximize it. I can make y1=1 and y2,y3,y4 smaller and the total of the four is as big as I can find. But I do not know that is what you want. $\endgroup$
    – Bill
    May 25 at 2:43
  • $\begingroup$ I think the fourth metric y4 is the most important, and I hope that y1, y2, y3, and y4 are all greater than 0.5 $\endgroup$ May 25 at 2:50

2 Answers 2

1
$\begingroup$

Some posibilities to maximize

(eqs = {Subscript[y, 1] == Subscript[x, 1], 
    Subscript[y, 2] == 1/(1 + 1/Subscript[x, 2]), 
    Subscript[y, 3] == (1 - 2*Subscript[x, 1])/(1 + Subscript[x, 2]) +
       Subscript[x, 1], 
    Subscript[y, 4] == 
     2/((1 + 1/Subscript[x, 2]) + 1/Subscript[x, 1])}) // TableForm

Plot3D[eqs[[3, 2]], {Subscript[x, 1], 0, 1}, {Subscript[x, 2], 0, 
  100}]

cond = Flatten@{0 < Subscript[x, 1] <= 1, 0 < Subscript[x, 2], 
   Thread[0 <= {Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], 
      Subscript[y, 4]} <= 1]}

Maximize everx yi independently

(max1 = Maximize[{#, cond}, {Subscript[x, 1], Subscript[x, 2], 
       Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[y,
        4]}] & /@ {Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], 
     Subscript[y, 4]}) // MatrixForm

Maximize sum of squared yi

sq = {Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[y, 
   4]}.{Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[
   y, 4]}

(max2 = Maximize[{sq, cond}, {Subscript[x, 1], Subscript[x, 2], 
    Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[y, 
    4]}])

(*   {4, {Subscript[x, 1] -> 1/2, Subscript[x, 2] -> 1, 
  Subscript[y, 1] -> 1, Subscript[y, 2] -> 1, Subscript[y, 3] -> 1, 
  Subscript[y, 4] -> 1}}   *)

Maximize sum of yi

tot = Total@{Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], 
   Subscript[y, 4]}

(max3 = Maximize[{tot, cond}, {Subscript[x, 1], Subscript[x, 2], 
    Subscript[y, 1], Subscript[y, 2], Subscript[y, 3], Subscript[y, 
    4]}])

(*   {4, {Subscript[x, 1] -> 1, Subscript[x, 2] -> 1, Subscript[y, 1] -> 1,
   Subscript[y, 2] -> 1, Subscript[y, 3] -> 1, Subscript[y, 4] -> 1}}   *)
$\endgroup$
0
$\begingroup$

Your constraints limit each $y_i$ to be at most $1$.
By choosing $x_1=1$ and $x_2$ large all of them get arbitrarily close to $1$:

With[{x1 = 1, x2 = 10000000},
 N[{x1, x2/(x2 + 1), x1 + (1 - 2 x1)/(1 + x2), (2 x1 x2)/(x1 x2 + x1 + x2)}]]
(* {1., 0.9999999, 0.9999999, 0.99999995} *)
$\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.