Skip to content

Commit 27d474f

Browse files
author
I800461
committed
misc
1 parent 565b1ca commit 27d474f

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

ww2-losses/src/main/java/rtss/ww2losses/Main.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ private HalfYearEntries<HalfYearEntry> evalHalves(
507507
evalHalves_with_births(halves, curr, p_mid1941, immigration_halves);
508508

509509
/* сгладить число рождений по времени, сделав непрерывным */
510-
new SmoothBirths().init_nonwar(ap, halves).calc();
510+
new SmoothBirths().init_nonwar(ap, halves).calc().to_nonwar(halves);
511+
512+
/* остальные полугодия: с рождениями, конечный расчёт их числа */
513+
evalHalves_with_births(halves, curr, p_mid1941, immigration_halves);
511514

512515
/*
513516
* Дополнительные данные для полугодий
@@ -632,7 +635,16 @@ private void evalHalves_with_births(
632635

633636
/* передвижка на следующие полгода населения с учётом рождений */
634637
ForwardPopulationT f_wb = new ForwardPopulationT();
635-
f_wb.setBirthRateTotal(ap.CBR_1940);
638+
if (prev.expected_nonwar_births_byday != null)
639+
{
640+
double[] m_births = WarHelpers.male_births(prev.expected_nonwar_births_byday);
641+
double[] f_births = WarHelpers.female_births(prev.expected_nonwar_births_byday);
642+
f_wb.setBirthCount(m_births, f_births);
643+
}
644+
else
645+
{
646+
f_wb.setBirthRateTotal(ap.CBR_1940);
647+
}
636648
f_wb.forward(pwb, prev.peace_mt, 0.5);
637649
if (immigration != null)
638650
pwb = pwb.add(immigration, ValueConstraint.NON_NEGATIVE);
@@ -1198,6 +1210,7 @@ private void evalDeathsForNewBirths_UnderPeacetimeChildMortality() throws Except
11981210
int ndays = fw.birthDays(0.5);
11991211

12001212
// добавить фактические рождения, распределив их по дням
1213+
// ###
12011214
double nb1 = he.prev.actual_births;
12021215
double nb2 = he.actual_births;
12031216
double nb3 = (he.next != null) ? he.next.actual_births : nb2;
@@ -1282,6 +1295,7 @@ private double fitDeathsForNewBirths(double multiplier, boolean record) throws E
12821295
double nb1 = he.prev.actual_births;
12831296
double nb2 = he.actual_births;
12841297
double nb3 = (he.next != null) ? he.next.actual_births : nb2;
1298+
// ###
12851299
double[] births = WarHelpers.births(ndays, nb1, nb2, nb3);
12861300
double[] m_births = WarHelpers.male_births(births);
12871301
double[] f_births = WarHelpers.female_births(births);

ww2-losses/src/main/java/rtss/ww2losses/helpers/SmoothBirths.java

+34-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class SmoothBirths
2424
private AreaParameters ap;
2525
private List<Bin> bins;
2626
private double[] births_1941_1st_halfyear;
27+
private double[] births;
2728

2829
public SmoothBirths init_nonwar(AreaParameters ap, HalfYearEntries<HalfYearEntry> halves) throws Exception
2930
{
@@ -71,7 +72,7 @@ public SmoothBirths init_actual(AreaParameters ap, HalfYearEntries<HalfYearEntry
7172
return this;
7273
}
7374

74-
public void calc() throws Exception
75+
public SmoothBirths calc() throws Exception
7576
{
7677
Bin[] abins = Bins.bins(bins);
7778
double[] averages = Bins.midpoint_y(abins);
@@ -84,21 +85,43 @@ public void calc() throws Exception
8485

8586
abins[0].avg = averages[0] = Util.average(births_1941_1st_halfyear);
8687

87-
double[] births = DisaggregateVariableWidthSeriesWithStartValues.disaggregate(averages,
88-
intervalWidths,
89-
maxIterations,
90-
smoothingSigma,
91-
positivityThreshold,
92-
maxConvergenceDifference,
93-
births_1941_1st_halfyear);
88+
births = DisaggregateVariableWidthSeriesWithStartValues.disaggregate(averages,
89+
intervalWidths,
90+
maxIterations,
91+
smoothingSigma,
92+
positivityThreshold,
93+
maxConvergenceDifference,
94+
births_1941_1st_halfyear);
9495

9596
if (!Util.isNonNegative(births))
9697
throw new Exception("Error calculating curve (negative value)");
9798

9899
CurveVerifier.validate_means(births, abins);
99100

100-
new ChartXY("Рождения " + ap.area, "x", "y")
101-
.addSeries("b1", births)
102-
.display();
101+
if (Util.False)
102+
{
103+
new ChartXY("Рождения " + ap.area, "x", "y")
104+
.addSeries("b1", births)
105+
.display();
106+
}
107+
108+
return this;
109+
}
110+
111+
public void to_nonwar(HalfYearEntries<HalfYearEntry> halves)
112+
{
113+
int nd = 0;
114+
115+
for (HalfYearEntry he : halves)
116+
{
117+
if (he.next == null)
118+
break;
119+
120+
he.expected_nonwar_births_byday = Util.splice(births, nd, nd + ndays - 1);
121+
122+
nd += ndays;
123+
}
124+
125+
Util.assertion(nd == births.length);
103126
}
104127
}

ww2-losses/src/main/java/rtss/ww2losses/population1941/PopulationMiddle1941.java

-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public PopulationForwardingResult1941 forward_1941_1st_halfyear(
6868
* Не пытаясь реконструировать кривую хода числа рождений в первом полугодии 1941 года,
6969
* мы приближаем её плоской линией.
7070
*/
71-
72-
// double[] births = WarHelpers.births(ndays, nbirths, nbirths, nbirths);
7371
double[] births = Util.normalize(Util.repeat(ndays, 1), nbirths);
7472
double[] m_births = WarHelpers.male_births(births);
7573
double[] f_births = WarHelpers.female_births(births);

0 commit comments

Comments
 (0)