![]() Algorithm & Code Sharing ⋅ Writings ⋅ Arts ⋅ About |
Simple Exponential Smoothing Algorithm for estimating demand in Demand Forecasting using Simple Exponential Smoothing (Adaptive method). Source Code: /* Demand Forecasting using Simple Exponential Smoothing. By: Muhammad Faruq Nuruddinsyah @ March 18, 2014. */ public class SES{ public static void main(String[] args){ new SES(); } public SES(){ final double ALPHA = 0.1; double[] demand = {8000, 13000, 23000, 34000, 10000, 18000, 23000, 38000, 12000, 13000, 32000, 41000}; int periodCycle = 4; double forecast = estimateDemand(13, demand, periodCycle, ALPHA); // Estimate demand for next period (13) System.out.println(forecast); } double estimateDemand(int period, double[] demand, int periodCycle, double alpha){ if(period > demand.length + 1){ return level(demand.length, demand, periodCycle, alpha); }else{ return level(period - 1, demand, periodCycle, alpha); } } double level(int period, double[] demand, int periodCycle, double alpha){ if(period == 0){ return levelZero(demand, periodCycle); }else{ return alpha * demand[period - 1] + (1.0 - alpha) * level(period - 1, demand, periodCycle, alpha); } } double levelZero(double[] demand, int periodCycle){ int result = 0; for(int i = 0; i < periodCycle; i++){ result += demand[i]; } return result / periodCycle; } } Lihat semua daftar ACS - Download: SES.java - Tanggal: 18 Maret 2014 - Kategori: Java |
© 2025 Muhammad Faruq Nuruddinsyah. All rights reserved. ![]() |