Title: Algebraic modeling in datalog
1Algebraic modeling in datalog
- Diego Klabjan, Jun Ma, Robert Fourer
Northwestern University
2Datalog
- Data query languages
- SQL, Xquery
- No procedural or declarative abilities
- Procedural and declarative languages
- No data querying capabilities
- Best of both worlds
DATALOG
3Algebraic Modeling
4SQL
- Modeling in SQL by Linderoth, Atamturk,
Savelsbergh - SQL mainly about querying
- Not suited for algebraic modeling
- Everything stored in tables
- Variables
- Constraints
- Modeling non intuitive
5Modeling in Datalog
- Powerful data capabilities
- Superset of SQL
- Data from database
- Querying and loading
- Declarative language
- Natural constructs
- Intuitive
- Hardly any development effort
6Modeling in datalog
- Given values to decision variables
- Easy to check feasibility
- Clearly not optimality
- Underlying logic programming in Datalog
- No extra effort required
- Not the case for most other algebraic modeling
languages
7Basic building blocks (Diet problem)
- Index sets
- NUTR(x), NUTRname(xn) -gt string(n). FOOD(x),
FOODname(xn) -gt string(n). - Parameters
- Input data
- Variables
- Buyf b -gt FOOD(f), float64(b),bgt0.
amtn, f a -gt NUTR(n), FOOD(f), float64(a),
a gt 0. nutrLown nL -gt NUTR(n),
float64(nL), nL gt 0. costf c -gt FOOD(f),
float64(c), c gt 0.
8Production/transportation model
- Multiple products (PROD), plants (ORIG) and
destinations (DEST) - Ship from plants to destinations
- Transportation problem for each product
9Production/transportation model
- Limited production capacity at each plant
- Objective to minimize production and
transportation costs
10Datalog Model
11Datalog model
12Datalog model
- Variables
- How much to transport
- How much to produce
- Other variables
- Integer replace float with int
- Binary are integer with upper bound of 1
13Datalog model
- Production availability
- sumTime predicate captures the left-hand side
- agg built-in aggregator
- Constraint negated (stratification restrictions
of Datalog)
14Datalog model
15Datalog model
16Datalog model
- Objective function
- Production cost
- Transportation cost
17Total cost
- Sum of the two cost components
18Enhanced modeling capabilities
- The fleeting model
- Assign fleets to flights
- Modeled as a multi-commodity network flow problem
- Network aspects
- Challenges
- Nodes at each airports sorted based on the
arrival/departure time in a circular fashion - Ordered and circular lists
19Flights
- Specification of flights
- Leg(l), Legname(ln) -gt string(n).
- Legtable(s1,t1,s2,t2,l) -gtStation(s1), Time(t1),
Station(s2), Time(t2), Leg(l). - LegtabledStationls1 -gtStation(s1), Leg(l).
- LegtabledTimelt1 -gt Time(t1), Leg(l).
- LegtableaStationls2 -gtStation(s2), Leg(l).
- LegtableaTimelt2 -gt Time(t2), Leg(l).
20NETWORk nodes
- For each station there is a timeline consisting
of network nodes - Either arrival or departure at station
node(s,t) -gt Station(s), Time(t). node(s,t) lt-
Legtable(s1,t1,_,_,_),(ss1, tt1)Legtable(_,_,
s2,t2,_),(ss2, tt2).
21Ordered Circular lists
- Declare next in the list
- Time is an integer-like structure to capture
times - nodenxts,t1 t2 -gt Station(s), Time(t1),
Time(t2). - Order
- nodenxts,t1 t2 lt- node(s,t1), node(s,t2),
(Timedatetimet1ltTimedatetimet2,!anythingInBe
tween(s, t1,t2) nodefrstst2,
nodelstst1).
22Missing aspects
- Piecewise linear functions
- Model them explicitly
- Unfortunately OS cannot handle them explicitly
- LogicBlox needs to convert them into a linear
mixed integer program - Disjunctions
- Nonlinear functions
- Long term goal