Message Boards Message Boards

0
|
7704 Views
|
4 Replies
|
5 Total Likes
View groups...
Share
Share this post:

[?] Maximize a multivariable function ?

Posted 7 years ago

I have used Maximize with a two-variable function :

Module[
{
\[Alpha] = 200,
c = 0.17,
b = 0.1,
e = 0.9,
k = 5000,
a = 10000,
t = 0.01 *Range[5],
m,
f
},

f[x0_, pList_] := (pList[[1]] - 
c - (b + t[[1]]) x0) (a - \[Alpha]  pList[[
1]] + \[Alpha]  50.1314) +
Sum[ (pList[[i]] - 
c - (b + t[[i]]) x0) (a - \[Alpha]  pList[[
i]] + \[Alpha]  pList[[i - 1]]), {i, 2, Length[t]}] - 
k (e - x0)^2;

Maximize[
{
f[\[FormalX], Array[\[FormalP], Length[t]]],
And @@ Thread[Array[\[FormalP], Length[t]] > 0] 
},
Flatten[{\[FormalX], Array[\[FormalP], Length[t]]}] 
]

]

But when i tried to add another variable (I changed f a bit), it is undefined in the Maximize argument (it is blue):

Module[
 {
  \[Alpha] = 100,
  \[Beta] = 10,
  c = 10,
  b = 0.05,
  e = 100,
  k = 500,
  a = 10000,
  t = 0.01 *Range[5],
  m,
  f
  },

 f[x0_, q_, 
   pList_] := (pList[[1]] - 
      c - (b + t[[1]]) x0) (a - \[Beta]  pList[[
        1]] + \[Beta] q - \[Alpha] q) +
   Sum[ (pList[[i]] - 
       c - (b + t[[i]]) x0) (a - \[Beta]  pList[[
         i]] + \[Beta]  pList[[i - 1]] - \[Alpha] q), {i, 2, 
     Length[t]}] - k (e - x0)^2;

 Maximize[
  {
   f[\[FormalX], p0 , Array[\[FormalP], Length[t]]],
    p0 > 0  And @@ Thread[Array[\[FormalP], Length[t]] > 0] 
   },
  Flatten[{\[FormalX], p0, Array[\[FormalP], Length[t]]}] 
  ]

 ]

I can't figure out what I did wrong

POSTED BY: Narjes Kandil
4 Replies

Note that Maximize defaults to NMaximize when the arguments are not infinite precision, so you might not be getting the global optimum.

POSTED BY: Frank Kampas
POSTED BY: Jon McLoone
Posted 7 years ago

I have to put it even if i'm using And ??

POSTED BY: Narjes Kandil

Missing comma between "p0>0" and "And"?

POSTED BY: Jon McLoone
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract