1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HEAL.Attic;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Algorithms.GradientDescent {
|
---|
30 | [StorableType("2A117076-0311-4F85-A1B9-16F39D5752DE")]
|
---|
31 | [Item("LbfgsState", "Internal state for the limited-memory BFGS optimization algorithm.")]
|
---|
32 | public sealed class LbfgsState : Item {
|
---|
33 | private alglib.minlbfgsstate state;
|
---|
34 | public alglib.minlbfgsstate State { get { return state; } }
|
---|
35 |
|
---|
36 | [StorableConstructor]
|
---|
37 | private LbfgsState(StorableConstructorFlag _) : base(_) { state = new alglib.minlbfgsstate(); }
|
---|
38 | private LbfgsState(LbfgsState original, Cloner cloner)
|
---|
39 | : base(original, cloner) {
|
---|
40 | if (original.state != null)
|
---|
41 | this.state = (alglib.minlbfgsstate)original.state.make_copy();
|
---|
42 | }
|
---|
43 |
|
---|
44 | public LbfgsState(alglib.minlbfgsstate state)
|
---|
45 | : base() {
|
---|
46 | this.state = (alglib.minlbfgsstate)state.make_copy();
|
---|
47 | }
|
---|
48 |
|
---|
49 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
50 | return new LbfgsState(this, cloner);
|
---|
51 | }
|
---|
52 |
|
---|
53 | #region persistence
|
---|
54 | [Storable]
|
---|
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; } }
|
---|
171 | [Storable]
|
---|
172 | private IList<Tuple<double, double>> RStateCa {
|
---|
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; } }
|
---|
204 | #endregion
|
---|
205 | }
|
---|
206 | }
|
---|