Changeset 18086 for branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GradientDescent/3.3/LbfgsState.cs
- Timestamp:
- 11/19/21 16:07:45 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GradientDescent/3.3/LbfgsState.cs
r17226 r18086 31 31 [Item("LbfgsState", "Internal state for the limited-memory BFGS optimization algorithm.")] 32 32 public sealed class LbfgsState : Item { 33 private alglib.minlbfgs .minlbfgsstate state;34 public alglib.minlbfgs .minlbfgsstate State { get { return state; } }33 private alglib.minlbfgsstate state; 34 public alglib.minlbfgsstate State { get { return state; } } 35 35 36 36 [StorableConstructor] 37 private LbfgsState(StorableConstructorFlag _) : base(_) { 38 state = new alglib.minlbfgs.minlbfgsstate(); 39 } 37 private LbfgsState(StorableConstructorFlag _) : base(_) { state = new alglib.minlbfgsstate(); } 40 38 private LbfgsState(LbfgsState original, Cloner cloner) 41 39 : base(original, cloner) { 42 this.state = new alglib.minlbfgs.minlbfgsstate(); 43 this.state.autobuf = CopyArray(original.state.autobuf); 44 this.state.d = CopyArray(original.state.d); 45 this.state.denseh = CopyArray(original.state.denseh); 46 this.state.diagh = CopyArray(original.state.diagh); 47 this.state.diffstep = original.state.diffstep; 48 this.state.epsf = original.state.epsf; 49 this.state.epsg = original.state.epsg; 50 this.state.epsx = original.state.epsx; 51 this.state.f = original.state.f; 52 this.state.fbase = original.state.fbase; 53 this.state.fm1 = original.state.fm1; 54 this.state.fm2 = original.state.fm2; 55 this.state.fold = original.state.fold; 56 this.state.fp1 = original.state.fp1; 57 this.state.fp2 = original.state.fp1; 58 this.state.g = CopyArray(original.state.g); 59 this.state.gammak = original.state.gammak; 60 this.state.k = original.state.k; 61 62 this.state.lstate.brackt = original.state.lstate.brackt; 63 this.state.lstate.dg = original.state.lstate.dg; 64 this.state.lstate.dginit = original.state.lstate.dginit; 65 this.state.lstate.dgm = original.state.lstate.dgm; 66 this.state.lstate.dgtest = original.state.lstate.dgtest; 67 this.state.lstate.dgx = original.state.lstate.dgx; 68 this.state.lstate.dgxm = original.state.lstate.dgxm; 69 this.state.lstate.dgy = original.state.lstate.dgy; 70 this.state.lstate.dgym = original.state.lstate.dgym; 71 this.state.lstate.finit = original.state.lstate.finit; 72 this.state.lstate.fm = original.state.lstate.fm; 73 this.state.lstate.ftest1 = original.state.lstate.ftest1; 74 this.state.lstate.fx = original.state.lstate.fx; 75 this.state.lstate.fxm = original.state.lstate.fxm; 76 this.state.lstate.fy = original.state.lstate.fy; 77 this.state.lstate.fym = original.state.lstate.fym; 78 this.state.lstate.infoc = original.state.lstate.infoc; 79 this.state.lstate.stage1 = original.state.lstate.stage1; 80 this.state.lstate.stmax = original.state.lstate.stmax; 81 this.state.lstate.stmin = original.state.lstate.stmin; 82 this.state.lstate.stx = original.state.lstate.stx; 83 this.state.lstate.sty = original.state.lstate.sty; 84 this.state.lstate.width = original.state.lstate.width; 85 this.state.lstate.width1 = original.state.lstate.width1; 86 this.state.lstate.xtrapf = original.state.lstate.xtrapf; 87 88 this.state.m = original.state.m; 89 this.state.maxits = original.state.maxits; 90 this.state.mcstage = original.state.mcstage; 91 this.state.n = original.state.n; 92 this.state.needf = original.state.needf; 93 this.state.needfg = original.state.needfg; 94 this.state.nfev = original.state.nfev; 95 this.state.p = original.state.p; 96 this.state.prectype = original.state.prectype; 97 this.state.q = original.state.q; 98 this.state.repiterationscount = original.state.repiterationscount; 99 this.state.repnfev = original.state.repnfev; 100 this.state.repterminationtype = original.state.repterminationtype; 101 this.state.rho = CopyArray(original.state.rho); 102 this.state.rstate.ba = CopyArray(original.state.rstate.ba); 103 this.state.rstate.ca = CopyArray(original.state.rstate.ca); 104 this.state.rstate.ia = CopyArray(original.state.rstate.ia); 105 this.state.rstate.ra = CopyArray(original.state.rstate.ra); 106 this.state.rstate.stage = original.state.rstate.stage; 107 108 this.state.s = CopyArray(original.state.s); 109 this.state.sk = CopyArray(original.state.sk); 110 this.state.stp = original.state.stp; 111 this.state.stpmax = original.state.stpmax; 112 this.state.theta = CopyArray(original.state.theta); 113 this.state.trimthreshold = original.state.trimthreshold; 114 this.state.work = CopyArray(original.state.work); 115 this.state.x = CopyArray(original.state.x); 116 this.state.xrep = original.state.xrep; 117 this.state.xupdated = original.state.xupdated; 118 this.state.yk = CopyArray(original.state.yk); 119 } 120 121 public LbfgsState(alglib.minlbfgs.minlbfgsstate state) 40 if (original.state != null) 41 this.state = (alglib.minlbfgsstate)original.state.make_copy(); 42 } 43 44 public LbfgsState(alglib.minlbfgsstate state) 122 45 : base() { 123 this.state = state;46 this.state = (alglib.minlbfgsstate)state.make_copy(); 124 47 } 125 48 … … 128 51 } 129 52 130 131 private T[] CopyArray<T>(T[] a) {132 var c = new T[a.Length];133 Array.Copy(a, c, c.Length);134 return c;135 }136 private T[,] CopyArray<T>(T[,] a) {137 var c = new T[a.GetLength(0), a.GetLength(1)];138 Array.Copy(a, c, c.Length);139 return c;140 }141 142 53 #region persistence 143 54 [Storable] 144 private double[] Autobuf { get { return state. autobuf; } set { state.autobuf = value; } }145 [Storable] 146 private double[] D { get { return state. d; } set { state.d = value; } }147 [Storable] 148 private double[,] Denseh { get { return state. denseh; } set { state.denseh = value; } }149 [Storable] 150 private double[] Diagh { get { return state. diagh; } set { state.diagh = value; } }151 [Storable] 152 private double Diffstep { get { return state. diffstep; } set { state.diffstep = value; } }153 [Storable] 154 private double Epsf { get { return state. epsf; } set { state.epsf = value; } }155 [Storable] 156 private double Epsg { get { return state. epsg; } set { state.epsg = value; } }157 [Storable] 158 private double Epsx { get { return state. epsx; } set { state.epsx = value; } }159 [Storable] 160 private double F { get { return state. f; } set { state.f = value; } }161 [Storable] 162 private double Fbase { get { return state. fbase; } set { state.fbase = value; } }163 [Storable] 164 private double Fm1 { get { return state. fm1; } set { state.fm1 = value; } }165 [Storable] 166 private double Fm2 { get { return state. fm2; } set { state.fm2 = value; } }167 [Storable] 168 private double Fold { get { return state. fold; } set { state.fold = value; } }169 [Storable] 170 private double Fp1 { get { return state. fp1; } set { state.fp1 = value; } }171 [Storable] 172 private double Fp2 { get { return state. fp2; } set { state.fp2 = value; } }173 [Storable] 174 private double[] G { get { return state. g; } set { state.g = value; } }175 [Storable] 176 private double Gammak { get { return state. gammak; } set { state.gammak = value; } }177 [Storable] 178 private int K { get { return state. k; } set { state.k = value; } }179 [Storable] 180 private bool LstateBrackt { get { return state. lstate.brackt; } set { state.lstate.brackt = value; } }181 [Storable] 182 private double LstateDg { get { return state. lstate.dg; } set { state.lstate.dg = value; } }183 [Storable] 184 private double LstateDginit { get { return state. lstate.dginit; } set { state.lstate.dginit = value; } }185 [Storable] 186 private double LstateDgm { get { return state. lstate.dgm; } set { state.lstate.dgm = value; } }187 [Storable] 188 private double LstateDgtest { get { return state. lstate.dgtest; } set { state.lstate.dgtest = value; } }189 [Storable] 190 private double LstateDgx { get { return state. lstate.dgx; } set { state.lstate.dgx = value; } }191 [Storable] 192 private double LstateDgxm { get { return state. lstate.dgxm; } set { state.lstate.dgxm = value; } }193 [Storable] 194 private double LstateDgy { get { return state. lstate.dgy; } set { state.lstate.dgy = value; } }195 [Storable] 196 private double LstateDgym { get { return state. lstate.dgym; } set { state.lstate.dgym = value; } }197 [Storable] 198 private double LstateFinit { get { return state. lstate.finit; } set { state.lstate.finit = value; } }199 [Storable] 200 private double LstateFm { get { return state. lstate.fm; } set { state.lstate.fm = value; } }201 [Storable] 202 private double LstateFtest1 { get { return state. lstate.ftest1; } set { state.lstate.ftest1 = value; } }203 [Storable] 204 private double LstateFx { get { return state. lstate.fx; } set { state.lstate.fx = value; } }205 [Storable] 206 private double LstateFxm { get { return state. lstate.fxm; } set { state.lstate.fxm = value; } }207 [Storable] 208 private double LstateFy { get { return state. lstate.fy; } set { state.lstate.fy = value; } }209 [Storable] 210 private double LstateFym { get { return state. lstate.fym; } set { state.lstate.fym = value; } }211 [Storable] 212 private int LstateInfoc { get { return state. lstate.infoc; } set { state.lstate.infoc = value; } }213 [Storable] 214 private bool LstateStage1 { get { return state. lstate.stage1; } set { state.lstate.stage1 = value; } }215 [Storable] 216 private double LstateStmax { get { return state. lstate.stmax; } set { state.lstate.stmax = value; } }217 [Storable] 218 private double LstateStmin { get { return state. lstate.stmin; } set { state.lstate.stmin = value; } }219 [Storable] 220 private double LstateStx { get { return state. lstate.stx; } set { state.lstate.stx = value; } }221 [Storable] 222 private double LstateSty { get { return state. lstate.sty; } set { state.lstate.sty = value; } }223 [Storable] 224 private double LstateWidth { get { return state. lstate.width; } set { state.lstate.width = value; } }225 [Storable] 226 private double LstateWidth1 { get { return state. lstate.width1; } set { state.lstate.width1 = value; } }227 [Storable] 228 private double LstateXtrapf { get { return state. lstate.xtrapf; } set { state.lstate.xtrapf = value; } }229 230 [Storable] 231 private int M { get { return state. m; } set { state.m = value; } }232 [Storable] 233 private int MaxIts { get { return state. maxits; } set { state.maxits = value; } }234 [Storable] 235 private int Mcstage { get { return state. mcstage; } set { state.mcstage = value; } }236 [Storable] 237 private int N { get { return state. n; } set { state.n = value; } }238 [Storable] 239 private bool Needf { get { return state. needf; } set { state.needf = value; } }240 [Storable] 241 private bool Needfg { get { return state. needfg; } set { state.needfg = value; } }242 [Storable] 243 private int Nfev { get { return state. nfev; } set { state.nfev = value; } }244 [Storable] 245 private int P { get { return state. p; } set { state.p = value; } }246 [Storable] 247 private int Prectype { get { return state. prectype; } set { state.prectype = value; } }248 [Storable] 249 private int Q { get { return state. q; } set { state.q = value; } }250 [Storable] 251 private int Repiterationscount { get { return state. repiterationscount; } set { state.repiterationscount = value; } }252 [Storable] 253 private int Repnfev { get { return state. repnfev; } set { state.repnfev = value; } }254 [Storable] 255 private int Repterminationtype { get { return state. repterminationtype; } set { state.repterminationtype = value; } }256 [Storable] 257 private double[] Rho { get { return state. rho; } set { state.rho = value; } }258 [Storable] 259 private bool[] RstateBa { get { return state. rstate.ba; } set { state.rstate.ba = value; } }55 private double[] Autobuf { get { return state.innerobj.autobuf; } set { state.innerobj.autobuf = value; } } 56 [Storable] 57 private double[] D { get { return state.innerobj.d; } set { state.innerobj.d = value; } } 58 [Storable] 59 private double[,] Denseh { get { return state.innerobj.denseh; } set { state.innerobj.denseh = value; } } 60 [Storable] 61 private double[] Diagh { get { return state.innerobj.diagh; } set { state.innerobj.diagh = value; } } 62 [Storable] 63 private double Diffstep { get { return state.innerobj.diffstep; } set { state.innerobj.diffstep = value; } } 64 [Storable] 65 private double Epsf { get { return state.innerobj.epsf; } set { state.innerobj.epsf = value; } } 66 [Storable] 67 private double Epsg { get { return state.innerobj.epsg; } set { state.innerobj.epsg = value; } } 68 [Storable] 69 private double Epsx { get { return state.innerobj.epsx; } set { state.innerobj.epsx = value; } } 70 [Storable] 71 private double F { get { return state.innerobj.f; } set { state.innerobj.f = value; } } 72 [Storable] 73 private double Fbase { get { return state.innerobj.fbase; } set { state.innerobj.fbase = value; } } 74 [Storable] 75 private double Fm1 { get { return state.innerobj.fm1; } set { state.innerobj.fm1 = value; } } 76 [Storable] 77 private double Fm2 { get { return state.innerobj.fm2; } set { state.innerobj.fm2 = value; } } 78 [Storable] 79 private double Fold { get { return state.innerobj.fold; } set { state.innerobj.fold = value; } } 80 [Storable] 81 private double Fp1 { get { return state.innerobj.fp1; } set { state.innerobj.fp1 = value; } } 82 [Storable] 83 private double Fp2 { get { return state.innerobj.fp2; } set { state.innerobj.fp2 = value; } } 84 [Storable] 85 private double[] G { get { return state.innerobj.g; } set { state.innerobj.g = value; } } 86 [Storable] 87 private double Gammak { get { return state.innerobj.gammak; } set { state.innerobj.gammak = value; } } 88 [Storable] 89 private int K { get { return state.innerobj.k; } set { state.innerobj.k = value; } } 90 [Storable] 91 private bool LstateBrackt { get { return state.innerobj.lstate.brackt; } set { state.innerobj.lstate.brackt = value; } } 92 [Storable] 93 private double LstateDg { get { return state.innerobj.lstate.dg; } set { state.innerobj.lstate.dg = value; } } 94 [Storable] 95 private double LstateDginit { get { return state.innerobj.lstate.dginit; } set { state.innerobj.lstate.dginit = value; } } 96 [Storable] 97 private double LstateDgm { get { return state.innerobj.lstate.dgm; } set { state.innerobj.lstate.dgm = value; } } 98 [Storable] 99 private double LstateDgtest { get { return state.innerobj.lstate.dgtest; } set { state.innerobj.lstate.dgtest = value; } } 100 [Storable] 101 private double LstateDgx { get { return state.innerobj.lstate.dgx; } set { state.innerobj.lstate.dgx = value; } } 102 [Storable] 103 private double LstateDgxm { get { return state.innerobj.lstate.dgxm; } set { state.innerobj.lstate.dgxm = value; } } 104 [Storable] 105 private double LstateDgy { get { return state.innerobj.lstate.dgy; } set { state.innerobj.lstate.dgy = value; } } 106 [Storable] 107 private double LstateDgym { get { return state.innerobj.lstate.dgym; } set { state.innerobj.lstate.dgym = value; } } 108 [Storable] 109 private double LstateFinit { get { return state.innerobj.lstate.finit; } set { state.innerobj.lstate.finit = value; } } 110 [Storable] 111 private double LstateFm { get { return state.innerobj.lstate.fm; } set { state.innerobj.lstate.fm = value; } } 112 [Storable] 113 private double LstateFtest1 { get { return state.innerobj.lstate.ftest1; } set { state.innerobj.lstate.ftest1 = value; } } 114 [Storable] 115 private double LstateFx { get { return state.innerobj.lstate.fx; } set { state.innerobj.lstate.fx = value; } } 116 [Storable] 117 private double LstateFxm { get { return state.innerobj.lstate.fxm; } set { state.innerobj.lstate.fxm = value; } } 118 [Storable] 119 private double LstateFy { get { return state.innerobj.lstate.fy; } set { state.innerobj.lstate.fy = value; } } 120 [Storable] 121 private double LstateFym { get { return state.innerobj.lstate.fym; } set { state.innerobj.lstate.fym = value; } } 122 [Storable] 123 private int LstateInfoc { get { return state.innerobj.lstate.infoc; } set { state.innerobj.lstate.infoc = value; } } 124 [Storable] 125 private bool LstateStage1 { get { return state.innerobj.lstate.stage1; } set { state.innerobj.lstate.stage1 = value; } } 126 [Storable] 127 private double LstateStmax { get { return state.innerobj.lstate.stmax; } set { state.innerobj.lstate.stmax = value; } } 128 [Storable] 129 private double LstateStmin { get { return state.innerobj.lstate.stmin; } set { state.innerobj.lstate.stmin = value; } } 130 [Storable] 131 private double LstateStx { get { return state.innerobj.lstate.stx; } set { state.innerobj.lstate.stx = value; } } 132 [Storable] 133 private double LstateSty { get { return state.innerobj.lstate.sty; } set { state.innerobj.lstate.sty = value; } } 134 [Storable] 135 private double LstateWidth { get { return state.innerobj.lstate.width; } set { state.innerobj.lstate.width = value; } } 136 [Storable] 137 private double LstateWidth1 { get { return state.innerobj.lstate.width1; } set { state.innerobj.lstate.width1 = value; } } 138 [Storable] 139 private double LstateXtrapf { get { return state.innerobj.lstate.xtrapf; } set { state.innerobj.lstate.xtrapf = value; } } 140 141 [Storable] 142 private int M { get { return state.innerobj.m; } set { state.innerobj.m = value; } } 143 [Storable] 144 private int MaxIts { get { return state.innerobj.maxits; } set { state.innerobj.maxits = value; } } 145 [Storable] 146 private int Mcstage { get { return state.innerobj.mcstage; } set { state.innerobj.mcstage = value; } } 147 [Storable] 148 private int N { get { return state.innerobj.n; } set { state.innerobj.n = value; } } 149 [Storable] 150 private bool Needf { get { return state.innerobj.needf; } set { state.innerobj.needf = value; } } 151 [Storable] 152 private bool Needfg { get { return state.innerobj.needfg; } set { state.innerobj.needfg = value; } } 153 [Storable] 154 private int Nfev { get { return state.innerobj.nfev; } set { state.innerobj.nfev = value; } } 155 [Storable] 156 private int P { get { return state.innerobj.p; } set { state.innerobj.p = value; } } 157 [Storable] 158 private int Prectype { get { return state.innerobj.prectype; } set { state.innerobj.prectype = value; } } 159 [Storable] 160 private int Q { get { return state.innerobj.q; } set { state.innerobj.q = value; } } 161 [Storable] 162 private int Repiterationscount { get { return state.innerobj.repiterationscount; } set { state.innerobj.repiterationscount = value; } } 163 [Storable] 164 private int Repnfev { get { return state.innerobj.repnfev; } set { state.innerobj.repnfev = value; } } 165 [Storable] 166 private int Repterminationtype { get { return state.innerobj.repterminationtype; } set { state.innerobj.repterminationtype = value; } } 167 [Storable] 168 private double[] Rho { get { return state.innerobj.rho; } set { state.innerobj.rho = value; } } 169 [Storable] 170 private bool[] RstateBa { get { return state.innerobj.rstate.ba; } set { state.innerobj.rstate.ba = value; } } 260 171 [Storable] 261 172 private IList<Tuple<double, double>> RStateCa { 262 get { return state. rstate.ca.Select(c => Tuple.Create(c.x, c.y)).ToList(); }263 set { state. rstate.ca = value.Select(t => new alglib.complex(t.Item1, t.Item2)).ToArray(); }264 } 265 [Storable] 266 private int[] RstateIa { get { return state. rstate.ia; } set { state.rstate.ia = value; } }267 [Storable] 268 private double[] RstateRa { get { return state. rstate.ra; } set { state.rstate.ra = value; } }269 [Storable] 270 private int RstateStage { get { return state. rstate.stage; } set { state.rstate.stage = value; } }271 [Storable] 272 private double[] S { get { return state. s; } set { state.s = value; } }273 [Storable] 274 private double[,] Sk { get { return state. sk; } set { state.sk = value; } }275 [Storable] 276 private double Stp { get { return state. stp; } set { state.stp = value; } }277 [Storable] 278 private double Stpmax { get { return state. stpmax; } set { state.stpmax = value; } }279 [Storable] 280 private double[] Theta { get { return state. theta; } set { state.theta = value; } }281 [Storable] 282 private double Trimthreshold { get { return state. trimthreshold; } set { state.trimthreshold = value; } }283 [Storable] 284 private double[] Work { get { return state. work; } set { state.work = value; } }285 [Storable] 286 private double[] X { get { return state. x; } set { state.x = value; } }287 [Storable] 288 private bool Xrep { get { return state. xrep; } set { state.xrep = value; } }289 [Storable] 290 private bool Xupdated { get { return state. xupdated; } set { state.xupdated = value; } }291 [Storable] 292 private double[,] Yk { get { return state. yk; } set { state.yk = value; } }173 get { return state.innerobj.rstate.ca.Select(c => Tuple.Create(c.x, c.y)).ToList(); } 174 set { state.innerobj.rstate.ca = value.Select(t => new alglib.complex(t.Item1, t.Item2)).ToArray(); } 175 } 176 [Storable] 177 private int[] RstateIa { get { return state.innerobj.rstate.ia; } set { state.innerobj.rstate.ia = value; } } 178 [Storable] 179 private double[] RstateRa { get { return state.innerobj.rstate.ra; } set { state.innerobj.rstate.ra = value; } } 180 [Storable] 181 private int RstateStage { get { return state.innerobj.rstate.stage; } set { state.innerobj.rstate.stage = value; } } 182 [Storable] 183 private double[] S { get { return state.innerobj.s; } set { state.innerobj.s = value; } } 184 [Storable] 185 private double[,] Sk { get { return state.innerobj.sk; } set { state.innerobj.sk = value; } } 186 [Storable] 187 private double Stp { get { return state.innerobj.stp; } set { state.innerobj.stp = value; } } 188 [Storable] 189 private double Stpmax { get { return state.innerobj.stpmax; } set { state.innerobj.stpmax = value; } } 190 [Storable] 191 private double[] Theta { get { return state.innerobj.theta; } set { state.innerobj.theta = value; } } 192 [Storable] 193 private double Trimthreshold { get { return state.innerobj.trimthreshold; } set { state.innerobj.trimthreshold = value; } } 194 [Storable] 195 private double[] Work { get { return state.innerobj.work; } set { state.innerobj.work = value; } } 196 [Storable] 197 private double[] X { get { return state.innerobj.x; } set { state.innerobj.x = value; } } 198 [Storable] 199 private bool Xrep { get { return state.innerobj.xrep; } set { state.innerobj.xrep = value; } } 200 [Storable] 201 private bool Xupdated { get { return state.innerobj.xupdated; } set { state.innerobj.xupdated = value; } } 202 [Storable] 203 private double[,] Yk { get { return state.innerobj.yk; } set { state.innerobj.yk = value; } } 293 204 #endregion 294 205 }
Note: See TracChangeset
for help on using the changeset viewer.