使用 Envision 进行概率预测的示例

使用 Envision 进行概率预测的示例


首页 » 资源 » 此处

下面的脚本说明了概率预测的生成过程。首先是针对交付周期生成概率预测,然后针对需求生成概率预测。预测值保存在 Ionic 数据文件中。 由于 CSV 等常规平面文件不支持直接导出分布型数据,因此必须使用 Ionic 格式。分出最终会扩展到网格中。

/// Probabilistic forecasts both for leadtime and demand
read "/sample/Lokad_Items.tsv"
read "/sample/Lokad_Orders.tsv" as Orders
read "/sample/Lokad_PurchaseOrders.tsv" as PO

path:="/sample/"

// Forecasting lead time distribution with purchase orders history
LeadTime = forecast.leadtime(
category: Brand, Category, SubCategory
supplier: Supplier
offset: 0
present: (max(Orders.Date) by 1) + 1
leadtimeDate: PO.Date
leadtimeValue: PO.DeliveryDate - PO.Date + 1
leadtimeSupplier: PO.Supplier)

// Forecasting demand using varying lead times and sales history
// (in practice, the ordering leadtime needs to be factored in as well)
Demand = forecast.demand(
category: Brand, Category, SubCategory
horizon: Leadtime
offset: 0
present: (max(Orders.Date) by 1) + 1
demandDate: Orders.Date
demandValue: Orders.Quantity)

// Persisting the distributions into a Ionic data file
show table "Distributions" export:"\{path}Lokad_Distrib.ion" with Id, Demand

//Extending the demand distribution into a grid
table Grid = extend.distrib(Demand)

show table "Grid" with
Id
Grid.Min as "Min"
Grid.Max as "Max"
Grid.Probability as "Probability"