I tried to implement "A simple strategy for varying the restart parameter in GMRES(m)" by A. H. Baker, E. R. Jessup, Tz. V. Kolev, 2007.
The idea is to minimise the number of Krylov spaces based on convergence to speed-up GMRES.
I tried to wrap it around the code from line 512 to 633.
Problems:
1: I was not able to overwrite krylov_dim in line 516. Why is that?
2: I am not sure, whether I calculate the convergence rate cr ( = cosine of the sequential angle ) correctly?
Am I on the wrong track with my implementation approach?
//Dynamicallycomputesthekrylov_dimforthenextiterationbasedoncurrentconvergencerate--------unsignedintm_min=3;unsignedintm_max=30;unsignedintm_old=30;unsignedintcr=1;/* convergence rate */unsignedinti=0;/* convergence rate */doublemax_cr=cos(8);/* max conv. rate = cosine of 8 degrees ≈ .99 */doublemin_cr=cos(80);/* min conv. rate = cosine of 80 degrees ≈ .175 */doubleres_old;unsignedintd=3;/* increment for adjusting */////DynamicGMRES//while(tag.error()>tag.tolerance()){/* calculate restart parameter mi */if(cr>max_cr||i==0)/* first cycle or near stagnation */krylov_dim=m_max;elseif(cr<min_cr)/* converging well */krylov_dim=m_min;else/* adjust */if((m_old-d)>=m_min)krylov_dim=(m_old-d);elsekrylov_dim=m_max;//GMRES512-633/* calculate convergence rate ( = cosine of the sequential angle) */i+=i;cr=std::fabs(res[k]/res_old);res_old=res[k];}//endwhile
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ad 1): What do you mean? krylov_dim is a local variable, so you can definitely overwrite it with whatever value you prefer. Make sure that your temporary work arrays are appropriately sized, though (that is, making krylov_dim smaller is no problem, but making krylov_dim larger than the initial value requires a larger set of Krylov vectors).
ad 2): cr looks alright. However, your cr_min and cr_max are likely to be wrong, because cos() takes radians instead of degrees.
Note: i += i; looks suspicious.
I'm curious: What are you expecting to gain from variable Krylov spaces?
Best regards,
Karli
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Karli,
I tried to implement "A simple strategy for varying the restart parameter in GMRES(m)" by A. H. Baker, E. R. Jessup, Tz. V. Kolev, 2007.
The idea is to minimise the number of Krylov spaces based on convergence to speed-up GMRES.
I tried to wrap it around the code from line 512 to 633.
Problems:
1: I was not able to overwrite krylov_dim in line 516. Why is that?
2: I am not sure, whether I calculate the convergence rate cr ( = cosine of the sequential angle ) correctly?
Am I on the wrong track with my implementation approach?
Hi tario,
ad 1): What do you mean?
krylov_dim
is a local variable, so you can definitely overwrite it with whatever value you prefer. Make sure that your temporary work arrays are appropriately sized, though (that is, makingkrylov_dim
smaller is no problem, but makingkrylov_dim
larger than the initial value requires a larger set of Krylov vectors).ad 2): cr looks alright. However, your
cr_min
andcr_max
are likely to be wrong, becausecos()
takes radians instead of degrees.Note:
i += i;
looks suspicious.I'm curious: What are you expecting to gain from variable Krylov spaces?
Best regards,
Karli
Have a look at the attached paper