A MATLAB framework for ordered numerical prediction using a PSO-optimized GM(1,1) trend and a PSO-initialized BP neural network for residual correction.
The final forecast is:
prediction = PSO-GM trend + PSO-BP residual
This is a clean implementation inspired by the referenced methodology. It is not a line-by-line reproduction of the legacy scripts or the paper.
- MATLAB R2020b or newer
- Deep Learning Toolbox
No Global Optimization Toolbox is required; PSO is implemented locally.
From the repository root:
run("examples/run_excavation_example.m")For a complete test and example run from a terminal:
powershell -ExecutionPolicy Bypass -File .\run_example.ps1chmod +x run_example.sh
./run_example.shThe example uses the first 45 ordered observations for model fitting and the
last 7 for independent testing. The fit function reserves the final 20% of its
input rows as a chronological validation block. It prints the test metrics and
saves four-panel value and single-step change figures under results/.
Each point is the current value minus the preceding value. The first test change is calculated against the final training value.
options = struct("Seed", 42, "HiddenSize", 5);
[model, info] = psogmbp.fit(X, y, options);
result = psogmbp.predict(model, XFuture);X is an n-by-p numeric feature matrix and y is a positive n-by-1
target vector. Rows are treated as chronological and are never shuffled.
XFuture must contain the known feature values for the next contiguous time
steps. The result table contains Trend, Residual, and Prediction.
| Option | Default | Meaning |
|---|---|---|
Seed |
42 |
Random seed |
ValidationFraction |
0.2 |
Final training rows used for validation |
GMWindow |
6 |
Recent target rows used by rolling GM(1,1) |
ResidualWindow |
8 |
Recent rolling residuals used by PSO-BP |
HiddenSize |
5 |
BP hidden neurons |
SwarmSize |
20 |
Particles in each PSO search |
MaxIterations |
50 |
PSO iterations |
Inertia |
0.8 |
PSO inertia weight |
Cognitive, Social |
1.49445 |
PSO learning factors |
WeightLimit |
1 |
BP weight search bound [-limit, limit] |
Epochs |
1000 |
Maximum BP training epochs |
Goal |
1e-6 |
BP performance goal |
MaxFail |
6 |
Validation failures before early stopping |
ShowWindow |
false |
Show MATLAB training UI |
data/excavation_monitoring.csv contains 52 anonymized, ordered observations:
step: sequence index, not a model featurestress_1,stress_2,water_settlement: external featurestarget: positive prediction target
The CSV contains values only; formulas, derived predictions, empty columns, and identifying project information were removed.
results = runtests("tests");
assert(all([results.Passed]));
run("examples/run_excavation_example.m");Tests cover deterministic training, an exponential GM trend, output decomposition, finite dimensions, and input validation. Run all three lines from the repository root for a complete test and visualization check.
- GM(1,1) currently requires a positive target series.
- The GM component uses a configurable recent window to follow changing trends.
- The BP component uses recent residuals so obsolete operating regimes do not dominate.
- Future external features must already be known or forecast upstream.
- The first release supports one target and one hidden BP layer.
- Small monitoring datasets can still overfit; held-out evaluation remains essential.
Zhang, Z.Y (2023). PSO-GM-BP Multivariate Model-Based Construction Engineering Deformation Prediction System V1.0. Computer Software Copyright Registration No. 2023SR1465171 (Certificate No. 12052344), China. Registered November 20, 2023.
MIT

