Alan Weiss <aweiss@mathworks.com> wrote in message <ms9om2$561$1@newscl01ah.mathworks.com>...
> On 9/2/2015 9:42 PM, Ganesh Ramkumar wrote:
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in message
> > <ms80rn$5m9$1@newscl01ah.mathworks.com>...
> >> "Ganesh Ramkumar" wrote in message
> >> <ms7kv3$9s4$1@newscl01ah.mathworks.com>...
> >> > Hi,
> >> > > I am trying to calculate the minimum of a function with multiple
> >> variables, the only constraints I have are the upper and lower bounds
> >> of the variables. The problem I am having is that fmincon does not
> >> change the input value from the initial guess value I give it.
> >> > > This is the output I get:
> >> > > initGuess =
> >> > > 0.6159
> >> > > > x =
> >> > > 0.6159
> >> >
> >
> >> > x =
> >> > > 0.6159
> >> > > > Initial point is a local minimum that satisfies the constraints.
> >> > > Optimization completed because at the initial point, the objective
> >> function is non-decreasing > in feasible directions to within the
> >> selected value of the function tolerance, and > constraints are
> >> satisfied to within the selected value of the constraint tolerance.
> >> > > <stopping criteria details>
> >> > > This is my call to fmincon:
> >> > A = [];
> >> > b = [];
> >> > Aeq = [];
> >> > beq = [];
> >> > lb = 0;
> >> > ub = 1;
> >> > initGuess = 0.6159;
> >> > options =
> >> optimset('TolX',1e-12,'TolCon',1e-12,'TolFun',1e-12,'Algorithm','interior-point');
> >>
> >> > [optAM,optBC] = fmincon(@(x)
> >> cmpBC(x,epochDate,epochDate2,root,rvfm),[initGuess],A,b,Aeq,beq,lb,ub,nonlcon,options);
> >>
> >> > > I tried multiple initial guesses and the same thing happens,
> >> please help not sure how fix this.
> >>
> >> The parameters used to call it, as well as your
> >> initial guess are essentially irrelevant, because we
> >> have absolutely NO idea what your function does
> >> or how it is written.
> >>
> >> The crystal ball is so foggy some days.
> >>
> >> However, a likely reason for why this might happen is that your
> >> function is piecewise constant. Effectively,
> >> I'd bet that somewhere inside the function, you
> >> essentially round something to integer form, or do
> >> something equivalently bad. Of course this must cause
> >> fmincon to fail, since that code presumes a differentiable
> >> objective. That requirement fails if you have done as
> >> I expect.
> >>
> >> Oh, one other thing. Why, for a one variable problem,
> >> are you bothering to use fmincon, when fminbnd is far
> >> easier to use? It too will have some issues with a
> >> function as I conjecture you have.
> >>
> >> John
> >
> > Hi John,
> >
> > I initially had it as multiple variable function and it was giving me
> > the issue mentioned above. So I tried it with one variable and the issue
> > persists.
> > My actual function is:
> > function output = computeBC(x,epochDate,epochDate2,root,rvfm)
> >
> >
> > epochDate = getNewTime(epochDate,x(2),'millisecond');
> > epochDate2 = getNewTime(epochDate2,x(3),'millisecond');
> >
> >
> > cmdParamString = ['HPOP */Satellite/COMDEV_Sat Drag On 2.2 '
> > num2str(x(1)) ' "NRLMSISE 2000" File "C:\Program Files (x86)\AGI\STK
> > 10\Data\sw20100101.txt"'];
> >
> >
> > root.ExecuteCommand(cmdParamString);
> >
> > cmd = horzcat('Propagate */Satellite/COMDEV_Sat', ' "', epochDate, '"
> > "', epochDate2,'"');
> > root.ExecuteCommand(cmd);
> > cmd = 'Report_RM */Satellite/COMDEV_Sat Style "J2000 Position Velocity"';
> > variableB = root.ExecuteCommand(cmd);
> > theSize = variableB.count;
> > posArray2=variableB.Item(theSize-2);
> >
> > C = strread(posArray2,'%s','delimiter',',');
> >
> >
> > output = norm([str2num(C{2})-rvfm(1) str2num(C{3})-rvfm(2)
> > str2num(C{4})-rvfm(3)]);%converted propagated results to km first then
> > find error
> >
> > end
> >
> > when I call fmincon:
> > A = [];
> >> > b = [];
> >> > Aeq = [];
> >> > beq = [];
> >> > lb = [0;-50;-50];
> >> > ub = [1,50,50];
> >> > initGuess = [0.6159,0,0];
> >> > options =
> >> optimset('TolX',1e-12,'TolCon',1e-12,'TolFun',1e-12,'Algorithm','interior-point');
> >>
> > [optAM,optBC] = fmincon(@(x)
> > cmpBC(x,epochDate,epochDate2,root,rvfm),initGuess,A,b,Aeq,beq,lb,ub,nonlcon,options);
> >
>
> While I cannot run your script, I suspect that John is correct, and that
> your function is not sensitive to small changes in x.
>
> Like him, I suggest that you try fminbnd first.
>
> Additionally, you could try some of the suggestions for finite
> differencing problems in the documentation:
> http://www.mathworks.com/help/optim/ug/optimizing-a-simulation-or-ordinary-differential-equation.html#btfl_2e
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
Yea I have tried fminbnd first but I can't use fminbnd for multiple variables.
> On 9/2/2015 9:42 PM, Ganesh Ramkumar wrote:
> > "John D'Errico" <woodchips@rochester.rr.com> wrote in message
> > <ms80rn$5m9$1@newscl01ah.mathworks.com>...
> >> "Ganesh Ramkumar" wrote in message
> >> <ms7kv3$9s4$1@newscl01ah.mathworks.com>...
> >> > Hi,
> >> > > I am trying to calculate the minimum of a function with multiple
> >> variables, the only constraints I have are the upper and lower bounds
> >> of the variables. The problem I am having is that fmincon does not
> >> change the input value from the initial guess value I give it.
> >> > > This is the output I get:
> >> > > initGuess =
> >> > > 0.6159
> >> > > > x =
> >> > > 0.6159
> >> >
> >
> >> > x =
> >> > > 0.6159
> >> > > > Initial point is a local minimum that satisfies the constraints.
> >> > > Optimization completed because at the initial point, the objective
> >> function is non-decreasing > in feasible directions to within the
> >> selected value of the function tolerance, and > constraints are
> >> satisfied to within the selected value of the constraint tolerance.
> >> > > <stopping criteria details>
> >> > > This is my call to fmincon:
> >> > A = [];
> >> > b = [];
> >> > Aeq = [];
> >> > beq = [];
> >> > lb = 0;
> >> > ub = 1;
> >> > initGuess = 0.6159;
> >> > options =
> >> optimset('TolX',1e-12,'TolCon',1e-12,'TolFun',1e-12,'Algorithm','interior-point');
> >>
> >> > [optAM,optBC] = fmincon(@(x)
> >> cmpBC(x,epochDate,epochDate2,root,rvfm),[initGuess],A,b,Aeq,beq,lb,ub,nonlcon,options);
> >>
> >> > > I tried multiple initial guesses and the same thing happens,
> >> please help not sure how fix this.
> >>
> >> The parameters used to call it, as well as your
> >> initial guess are essentially irrelevant, because we
> >> have absolutely NO idea what your function does
> >> or how it is written.
> >>
> >> The crystal ball is so foggy some days.
> >>
> >> However, a likely reason for why this might happen is that your
> >> function is piecewise constant. Effectively,
> >> I'd bet that somewhere inside the function, you
> >> essentially round something to integer form, or do
> >> something equivalently bad. Of course this must cause
> >> fmincon to fail, since that code presumes a differentiable
> >> objective. That requirement fails if you have done as
> >> I expect.
> >>
> >> Oh, one other thing. Why, for a one variable problem,
> >> are you bothering to use fmincon, when fminbnd is far
> >> easier to use? It too will have some issues with a
> >> function as I conjecture you have.
> >>
> >> John
> >
> > Hi John,
> >
> > I initially had it as multiple variable function and it was giving me
> > the issue mentioned above. So I tried it with one variable and the issue
> > persists.
> > My actual function is:
> > function output = computeBC(x,epochDate,epochDate2,root,rvfm)
> >
> >
> > epochDate = getNewTime(epochDate,x(2),'millisecond');
> > epochDate2 = getNewTime(epochDate2,x(3),'millisecond');
> >
> >
> > cmdParamString = ['HPOP */Satellite/COMDEV_Sat Drag On 2.2 '
> > num2str(x(1)) ' "NRLMSISE 2000" File "C:\Program Files (x86)\AGI\STK
> > 10\Data\sw20100101.txt"'];
> >
> >
> > root.ExecuteCommand(cmdParamString);
> >
> > cmd = horzcat('Propagate */Satellite/COMDEV_Sat', ' "', epochDate, '"
> > "', epochDate2,'"');
> > root.ExecuteCommand(cmd);
> > cmd = 'Report_RM */Satellite/COMDEV_Sat Style "J2000 Position Velocity"';
> > variableB = root.ExecuteCommand(cmd);
> > theSize = variableB.count;
> > posArray2=variableB.Item(theSize-2);
> >
> > C = strread(posArray2,'%s','delimiter',',');
> >
> >
> > output = norm([str2num(C{2})-rvfm(1) str2num(C{3})-rvfm(2)
> > str2num(C{4})-rvfm(3)]);%converted propagated results to km first then
> > find error
> >
> > end
> >
> > when I call fmincon:
> > A = [];
> >> > b = [];
> >> > Aeq = [];
> >> > beq = [];
> >> > lb = [0;-50;-50];
> >> > ub = [1,50,50];
> >> > initGuess = [0.6159,0,0];
> >> > options =
> >> optimset('TolX',1e-12,'TolCon',1e-12,'TolFun',1e-12,'Algorithm','interior-point');
> >>
> > [optAM,optBC] = fmincon(@(x)
> > cmpBC(x,epochDate,epochDate2,root,rvfm),initGuess,A,b,Aeq,beq,lb,ub,nonlcon,options);
> >
>
> While I cannot run your script, I suspect that John is correct, and that
> your function is not sensitive to small changes in x.
>
> Like him, I suggest that you try fminbnd first.
>
> Additionally, you could try some of the suggestions for finite
> differencing problems in the documentation:
> http://www.mathworks.com/help/optim/ug/optimizing-a-simulation-or-ordinary-differential-equation.html#btfl_2e
>
> Good luck,
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
Yea I have tried fminbnd first but I can't use fminbnd for multiple variables.