Skip to content

Commit 14fcbdf

Browse files
committed
repeat VFSA process more than once
The repeat parameter in Mvfsacrenh.c program allows to repeat the VFSA global optimization process more times, using last opyimized parameters as input to the new VFSA optimization attempt.
1 parent 51a890c commit 14fcbdf

File tree

2 files changed

+55
-47
lines changed

2 files changed

+55
-47
lines changed

Mvfsacrenh.c

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ int main(int argc, char* argv[])
3636
float Em0=0; // Major semblance
3737
float u; // Random number
3838
float ***t; // Data cube A(m,h,t)
39-
int q; // counter
39+
int q, i; // loop counter
4040
float semb; // Semblance - actual iteration
4141
float RN, RNIP, BETA; // CRS parameters
4242
float semb0; // Inicial semblance value
4343
float c0; // VFSA damping factor
4444
float temp0; // inicial VFSA temperature
4545
float temp; // VFSA temperature
46+
int repeat; // perform VFSA optimization more than once
4647

4748
/* RSF files I/O */
4849
sf_file in, out;
@@ -70,6 +71,9 @@ int main(int argc, char* argv[])
7071
if (!sf_getfloat("temp0",&temp0)) temp0=10;
7172
/* inicial VFSA temperature */
7273

74+
if(!sf_getint("repeat",&repeat)) repeat=1;
75+
/* How many times to perform VFSA global optimization */
76+
7377
if (!sf_histint(in,"n1",&nt)) sf_error("No n1= in input");
7478
if (!sf_histfloat(in,"d1",&dt)) sf_error("No d1= in input");
7579
if (!sf_histfloat(in,"o1",&ot)) sf_error("No o1= in input");
@@ -87,7 +91,7 @@ int main(int argc, char* argv[])
8791

8892
sf_warning("Active mode on!!!");
8993
sf_warning("Command line parameters: ");
90-
sf_warning("m0=%f v0=%f t0=%f c0=%f temp0=%f",m0,v0,t0,c0,temp0);
94+
sf_warning("m0=%f v0=%f t0=%f c0=%f temp0=%f repeat=%i",m0,v0,t0,c0,temp0,repeat);
9195
sf_warning("Input file parameters: ");
9296
sf_warning("n1=%i d1=%f o1=%f",nt,dt,ot);
9397
sf_warning("n2=%i d2=%f o2=%f",nh,dh,oh);
@@ -109,54 +113,58 @@ int main(int argc, char* argv[])
109113

110114
semb0=0;
111115

112-
for (q=0; q <ITMAX; q++){
113-
114-
/* calculate VFSA temperature for this iteration */
115-
temp=getVfsaIterationTemperature(q,c0,temp0);
116-
117-
/* parameter disturbance */
118-
disturbParameters(temp,cnew,c);
119-
120-
RN = cnew[0];
121-
RNIP = cnew[1];
122-
BETA = cnew[2];
123-
124-
semb=0;
125-
126-
/* Calculate semblance: Non-hyperbolic CRS approximation with data */
127-
semb=semblance(m0,dm,om,oh,dh,dt,nt,t0,v0,RN,RNIP,BETA,t);
128-
129-
/* VFSA parameters convergence condition */
130-
if(fabs(semb) > fabs(semb0) ){
131-
otsemb = semb;
132-
otrn = RN;
133-
otrnip = RNIP;
134-
otbeta = BETA;
135-
semb0 = semb;
136-
}
116+
for(i=0;i<repeat;i++){
117+
118+
for (q=0; q <ITMAX; q++){
119+
120+
/* calculate VFSA temperature for this iteration */
121+
temp=getVfsaIterationTemperature(q,c0,temp0);
122+
123+
/* parameter disturbance */
124+
disturbParameters(temp,cnew,c);
125+
126+
RN = cnew[0];
127+
RNIP = cnew[1];
128+
BETA = cnew[2];
137129

138-
/* VFSA parameters update condition */
139-
deltaE = -semb - Em0;
140-
141-
/* Metrópolis criteria */
142-
PM = expf(-deltaE/temp);
143-
144-
if (deltaE<=0){
145-
c[0] = cnew[0];
146-
c[1] = cnew[1];
147-
c[2] = cnew[2];
148-
Em0 = -semb;
149-
} else {
150-
u=getRandomNumberBetween0and1();
151-
if (PM > u){
130+
semb=0;
131+
132+
/* Calculate semblance: Non-hyperbolic CRS approximation with data */
133+
semb=semblance(m0,dm,om,oh,dh,dt,nt,t0,v0,RN,RNIP,BETA,t);
134+
135+
/* VFSA parameters convergence condition */
136+
if(fabs(semb) > fabs(semb0) ){
137+
otsemb = semb;
138+
otrn = RN;
139+
otrnip = RNIP;
140+
otbeta = BETA;
141+
semb0 = semb;
142+
}
143+
144+
/* VFSA parameters update condition */
145+
deltaE = -semb - Em0;
146+
147+
/* Metrópolis criteria */
148+
PM = expf(-deltaE/temp);
149+
150+
if (deltaE<=0){
152151
c[0] = cnew[0];
153152
c[1] = cnew[1];
154153
c[2] = cnew[2];
155154
Em0 = -semb;
155+
} else {
156+
u=getRandomNumberBetween0and1();
157+
if (PM > u){
158+
c[0] = cnew[0];
159+
c[1] = cnew[1];
160+
c[2] = cnew[2];
161+
Em0 = -semb;
162+
}
156163
}
157-
}
158-
159-
} /*loop over iterations */
164+
165+
} /* loop over iterations */
166+
167+
} /* repeat VFSA global optimization */
160168

161169

162170
/* Save optimized parameters in 'param' file */

experiments/vfsacrenh/SConstruct

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ Flow('dataCube','gaussianReflector reflectorDip',
5555
''')
5656

5757
m0=5
58-
t0=1.2
58+
t0=1.1
5959
v0=1.5
6060

6161
# Very Fast Simulated Aneelling Global Optimization (VFSA)
6262
Flow('crsParameters','dataCube',
6363
'''
64-
vfsacrenh m0=%g v0=%g t0=%g verb=y
64+
vfsacrenh m0=%g v0=%g t0=%g verb=y repeat=2
6565
''' % (m0,v0,t0))
6666

6767
# Aproximation Error
@@ -88,7 +88,7 @@ Flow('error',['crsAppSurface','dataReflectionSurface'],
8888
''')
8989
Plot('error',
9090
'''
91-
grey color=j bias=2 scalebar=y barlabel=Time barunit=s barreverse=y
91+
grey color=j scalebar=y barlabel=Time barunit=s barreverse=y
9292
title="Approximation error" label1=Half-Offset unit1=km label2=Midpoint unit2=km
9393
maxval=1 minval=0
9494
''')

0 commit comments

Comments
 (0)