Fix nonlinearprogram

1. Previously `NonlinearProgram` gives incorrect gradient if the `xind` in `addConstraint` contains duplicate variables, for example
```
cnstr = FunctionHandleConstraint(-1,1,2,@(x,y) x+y);
prog = prog.addNonlinearConstraint(cnstr,[1;1])
```
I fix this in a not very clean way (uses for loop)
2. If we add an empty linear constraint in `NonlinearProgram` and then delete it, the program will fail. Now it accepts empty linear constraint.
i think it’s awesome to catch this, but we probably don’t want to pollute the code.  I’d vote for an error, and removing the duplicate var indices logic.  what do others think?
On Dec 4, 2014, at 10:14 AM, Hongkai Dai <notifications@github.com> wrote:

> In solvers/NonlinearProgram.m:
> 
> > @@ -313,6 +319,12 @@
> >        obj.num_ceq = obj.num_ceq + length(cnstr.ceq_idx);
> >        obj.nlcon_xind{end+1} = xind;
> >        obj.nlcon_xind_stacked{end+1} = xind_vec;
> > +      if(length(unique(xind_vec)) ~= length(xind_vec))
> > +        warning('Drake:NonlinearProgram:DuplicateVarNLcon','The input nonlinear constraint has the same decision variable being used duplicatedly as input argument, for example f(x,x) = x+x, consider to combine the input argument to remove the duplicity, by writing f(x) = 2*x');
> We can throw an error, and we will require that the input `xind` are all different, the non-uniqueness definitely makes the problem a lot worse. Some of our code passes non-unique `xind`, and the constraint gradient was wrong. I can throw an error here if you think that is a better solution.
> …
> —
> Reply to this email directly or view it on GitHub.
>