1
$\begingroup$

For the following matrix

$$M = \begin{pmatrix} f1[x,y,z] & f2[x,y,z]\\ g1[x,y,z] & g2[x,y,z]\\ h1[x,y,z] & h2[x,y,z] \end{pmatrix} $$

with

f1[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + 0.1 Sqrt[z]]^2)
g1[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + 0.1 I Sqrt[z]]^2)
h1[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + Sqrt[z]]^2)

f2[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z]])
g2[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - x]])
h2[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - y]])

Now I want to optimise the value of:

P = f1[x,y,z] pos[1] + f2[x,y,z] pos[2]

where pos[j] returns the row corresponding to the highest value in column j . However, I don't know how to define pos[j]. I currently have

MWE

pos[1] = Position[{f1[x,y,z], g1[x,y,z], h1[x,y,z]]}, Max[f1[x,y,z], g1[x,y,z], h1[x,y,z]]]

pos[2] = Position[{f2[x,y,z], g2[x,y,z], h2[x,y,z]]}, Max[f2[x,y,z], g2[x,y,z], h2[x,y,z]]]

Poptimized = Maximize[P, {x, y, z}]

But this is not working. This is since pos[1] and pos[2] return empty lists. I thought that wrapping it inside the Maximize would have it evaluate. I want something structured as follows:

Maximize[f1[x,y,z] pos[1] + f2[x,y,z] pos[2],{x,y,z}]

where pos[1] and pos[2] both also depend on x,y,z and so need to be optimised too.

$\endgroup$
7
  • $\begingroup$ Shouldn't you use f1[x_,y_,z_] := ...? $\endgroup$
    – anderstood
    Dec 4, 2019 at 19:18
  • $\begingroup$ Yes, that was a typo ... $\endgroup$
    – Sid
    Dec 4, 2019 at 19:20
  • $\begingroup$ f2=g2=h2?.... $\endgroup$ Dec 4, 2019 at 19:36
  • $\begingroup$ Does ArgMax do what you want? $\endgroup$
    – bill s
    Dec 4, 2019 at 19:50
  • $\begingroup$ $x\in Reals$ why do you need Im[x]=0 and so f1[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + 0.1 Sqrt[z]]^2)= f1[x_,y_,z_] := E^(-Abs[y Sqrt[1 - z] + 0.1 Sqrt[z]]^2) $\endgroup$ Dec 4, 2019 at 20:00

1 Answer 1

1
$\begingroup$

Not a complete answer but try this. Since all function has the same max value, how do you decide which function you choose? Mathematica chose the last one.

M = {{-x - y^2 - 2 z , x - y^2 + 2 z },
{-x - y - z^2, x + 2 y + z^2},
{-x - y - z^3, 2 x - y + z}};

$M=\left( \begin{array}{cc} -x-y^2-2 z & x-y^2+2 z \\ -x-y-z^2 & x+2 y+z^2 \\ -x-y-z^3 & 2 x-y+z \\ \end{array} \right)$

pos1 = First@Ordering[MaxValue[#, {x, y, z}] & /@ M[[All, 1]], -1]
pos2 = First@Ordering[MaxValue[#, {x, y, z}] & /@ M[[All, 2]], -1]

P = NMaximize[M[[1,1]] pos1 + M[[1,2]] pos2,{x, y, z}]
$\endgroup$
7
  • $\begingroup$ You are correct that each row has two columns. However, I am trying to find the maximum values in each column. Hence, for the above example, pos[1] looks for the row corresponding to the max value in column 1. That is pos[1]=Ordering[MaxValue[#, {x, y, z}] & /@ func, -1]. $\endgroup$
    – Sid
    Dec 6, 2019 at 18:06
  • $\begingroup$ I want to then determine the optimised value for P = f1[x,y,z] pos[1] + f2[x,y,z] pos[2], where f1[x,y,z] = x + y^2 + 2z and f2[x,y,z] = x + y + z^2. Can I use your above code inside the Maximize function? $\endgroup$
    – Sid
    Dec 6, 2019 at 18:12
  • $\begingroup$ I want something structured as follows: Maximize[f1[x,y,z] pos[1] + f2[x,y,z] pos[2],{x,y,z}]. How can I define pos[j] such that it it takes performs the optimisation and returns the row position as described in the question? $\endgroup$
    – Sid
    Dec 6, 2019 at 18:43
  • $\begingroup$ These functions are unbounded above f1[x,y,z] = x + y^2 + 2z and f2[x,y,z] = x + y + z^2 Can you edit the question with your real problem if it is not too complicated. $\endgroup$ Dec 6, 2019 at 20:24
  • $\begingroup$ The actual functions i'm using are very lengthy. However x, y, z are all finite. Can you describe how pos1 is defined please? It's correctly looking at column 1, but how is it looking for the MaxValue? (i.e. what values for x,y,z is it using to determine which is largest) $\endgroup$
    – Sid
    Dec 6, 2019 at 22:57

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.