Re: Request for help - Minimize

*To*: mathgroup at smc.vnet.net*Subject*: [mg97466] Re: Request for help - Minimize*From*: Szabolcs Horvát <szhorvat at gmail.com>*Date*: Sat, 14 Mar 2009 05:34:12 -0500 (EST)*References*: <gpda88$jnm$1@smc.vnet.net>

zhuoxin lee wrote: > Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? > > Array[CE,100] > For[i =1,i<=100,i++, > > CE[i] = Minimize [objfun[i],constraints[i]] > > ] > First, this is better written as Table[Minimize[{objfun[i], constraints[i]}, variables], {i, 1, 100}] but this does not filter out the cases that throw errors. You can use check for this: Table[ Check[ Minimize[{objfun[i], constraints[i]}, variables], "error" ], {i, 1, 100}] If you're new to Mathematica, it is a good idea to try to avoid For[]. In most cases there are easier/faster alternatives.