Sergey.Bochkanov wrote:
It is possible to place such limit on step length, but it will require modification of the ALGLIB internals. Fortunately, you can do it yourself with only a little guidance from my side.
There are two places in the minasa subpackage where step can be limited: a) internal iterations of the gradient projection algorithm, and b) internal internal iterations of the nonlinear CG. You have to apply modifications to both places.
1. you should find "Two types of search are needed because we can't" in the source of the optimization package. You can find if/then block several lines below with ASAD1Norm(State)<=State.StpMax condition. You have to replace it by max(i=0..n-1 : abs(state.d[i]))<=State.StpMax. These lines correspond to unit step in the direction given by State.D.
2. after "alpha=1 is too large, try smaller values" you can find if/then block if State.StpMax>0 then State.Stp:=Min(State.Stp,State.StpMax). You should replace this if/then block by loop which calculates upper limit on State.Stp. You should make sure that Abs(State.D[])*State.Stp<=step_limit for all i=0..n-1. Be careful because State.D[] can be zero for some i (exactly zero, if we are at the boundary given by BndL or BndU).
3. finally, you should find two calls to MCSRCH() function below the "Make a CG step in direction given by DK[]" line. These calls use State.StpMax as upper limit on the step length. You should calculate your own step limit using same condition Abs(State.D[])*State.CurrentStepLimit<=step_limit. I recommend you to calculate it once before the first call to the MCSRCH(), and to store it as the member of the State object. Never use locals to store information because minasaiteration() function periodically returns to the calling subroutine and all information stored by you in the local variables will be lost.
It's so kind of you to help me like this.
Thanks for your answer very much :-)