navigation

Lokad’s Technical Documentation

Envision is the Domain Specific programming Language (DSL) developed by Lokad. Envision is dedicated to the predictive optimization of supply chains. While the Lokad platform includes many features beyond Envision, the bulk of Lokad’s capabilities are delivered through this DSL. In order to create a supply chain optimization app with Lokad, the Supply Chain Scientist is expected to write code, more specifically Envision code.

show label "Hello World" a1b1

This script produces a dashboard containing a single tile of type label, spreading over two cells A1 and B1 following the Excel grid conventions (letters designate columns, numbers designate lines).

To run this script, go to try.lokad.com, this is the Envision code playground.
A commercial version with more capabilities than the playground is also available.
Post any Envision-related questions on our public forum.

Envision supports numeric calculations.

// Text following a double-slash is a comment
a = 5
b = (a + 1) * 3 / 4
show scalar "Result will be 4.5" a1b1 with b // display a simple tile

Envision loads data from flat files, as commonly extracted from enterprise systems.

read "/sample/orders.csv" as Orders expect [date] with
  Date : date
  Quantity : number

show linechart "Daily Quantities" a1b4 with sum(Orders.Quantity)

Envision adopts array programming, processing whole columns at once, like SQL. Envision is space sensitive, much like Python.

table Orders = with // hard-coding a table
  [| as Sku, as Date          , as Qty, as Price |] // headers
  [| "a",    date(2020, 1, 17), 5     , 1.5      |]
  [| "b",    date(2020, 2, 5) , 3     , 7.0      |]
  [| "b",    date(2020, 2, 7) , 1     , 2.0      |]
  [| "c",    date(2020, 2, 15), 7     , 5.7      |]

Orders.Amount = Orders.Qty * Orders.Price // all lines at once

show table "Total Sales by SKU" a1b3 with
  Orders.Sku as "SKUs"                         // 1st column
  sum(Orders.Amount) as "Amount" { unit:"$" }  // 2nd column
  group by Orders.Sku

Envision approaches machine learning through Differentiable Programming.

table T = with
  [| as X, as Y |]
  [| 1, 3.1 |]
  [| 2, 3.9 |]
  [| 3, 5.1 |]
  [| 4, 6.0 |]
 
autodiff T with // automatic differentiation
  params a auto // 1st parameter 
  params b auto // 2nd parameter
  return (a * T.X + b - T.Y)^2 // loss for the stochatic gradient descent
 
show scalar "Learned" a1c1 with "y ≈ \{a} x + \{b}"

Envision approaches probabilistic modelling through a random variable algebra and Monte Carlo blocks.

montecarlo 1000 with // approximate π value
  x = random.uniform(-1, 1)
  y = random.uniform(-1, 1)
  inCircle = x^2 + y^2 < 1
  sample approxPi = avg(if inCircle then 4 else 0)
show scalar "π approximation" with approxPi // 3.22

Envision features a sub-language named StyleCode, inspired by CSS, to modify the tiles look & feel.

table Products = with
 [| as Product, as Color |]
 [| "pants", "blue" |]
 [| "shirt", "pink" |]
 [| "socks", "green"|]

show table "My Products" a1b3 with
  Products.Product { textColor: #[Products.Color] } // curly brackets for StyleCode
  Products.Color