Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2114

NMaximize inconsistency

From Jingjing Wang <brightapple2008@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject NMaximize inconsistency
Date 2011-05-04 23:46 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ipsogs$89g$1@smc.vnet.net> (permalink)

Show all headers | View raw


Dear Group,

I wrote an example to test NMaximize for solving optimization problem
with many constraints. Here are the results when I first run it:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
T = 3;

a = Table[x[t], {t, T}]
b = Table[y[t], {t, T}]

{x[1], x[2], x[3]}

{y[1], y[2], y[3]}

NMaximize[{Sum[x[t]^2 - y[t], {t, T}],
  Table[x[t] == x[t - 1]^2 + 2 y[t - 1], {t, T}],
  Table[y[t] == x[t] + x[t + 1], {t, T - 1}], x[0] == 1, y[0] == 1},
 Join[a, b]]

{38465.7, {x[1] -> 3., x[2] -> -15., x[3] -> -195., y[1] -> -12.,
  y[2] -> -210., y[3] -> 15.3005}}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

But when I tried to run it the next day, NMaixmize doesn't work....

>>>>>>>>>>>>>>>>>>>>>>>>

In[191]:= T = 3;

In[192]:= a = Table[x[t], {t, T}]
b = Table[y[t], {t, T}]

Out[192]= {x[1], x[2], x[3]}

Out[193]= {y[1], y[2], y[3]}

In[194]:= NMaximize[{Sum[x[t]^2 - y[t], {t, T}],
  Table[x[t] == x[t - 1]^2 + 2 y[t - 1], {t, T}],
  Table[y[t] == x[t] + x[t + 1], {t, T - 1}], x[0] == 1, y[0] == 1},
 Join[a, b]]

During evaluation of In[194]:= NMaximize::bcons: The following
constraints are not valid: {x[0]==1,y[0]==1,x[0]^2+2
y[0]==x[1],y[1]==x[1]+x[2],x[1]^2+2
y[1]==x[2],y[2]==x[2]+x[3],x[2]^2+2 y[2]==x[3]}. Constraints should be
equalities, inequalities, or domain specifications involving the
variables. >>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 Any idea why?

Thanks!-JJ

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

NMaximize inconsistency Jingjing Wang <brightapple2008@gmail.com> - 2011-05-04 23:46 +0000

csiph-web