DSL Compilation

This document describes how the Objective Function DSL is compiled into JuMP Julia macros. For now it simply consists of several DSL examples and the generated Julia code.

sense: min
context:
    method: sum
    for:
        t: transport
quantity: t.distance
@defVar(model, _value, Int)
@addConstraint(model, _value == sum{distance[t],t=TA})
@setObjective(model, Min, _value)
sense: min
context:
    method: sum
    for:
        c1: commodity
        c2: commodity
quantity:
    absolute_value:
        - subtract:
            - subtract:
                - c1.dropoff_time
                - c1.request_time
            - subtract:
                - c2.dropoff_time
                - c2.request_time
@defVar(model, _value, Int)
@defVar(model, _tmp1[DA,DA], Int)
@defVar(model, _tmp2[DA,DA], Int)
@defVar(model, _tmp3[DA,DA], Int)
@defVar(model, _tmp4[DA,DA], Int)
@defVar(model, pos_tmp4[DA,DA] >= 0, Int)
@defVar(model, neg_tmp4[DA,DA] >= 0, Int)
for c1 in DA
for c2 in DA
@addConstraint(model, _tmp1[c1,c2] == dropoff_time[c1] - parameters["request_time"][c1])
@addConstraint(model, _tmp2[c1,c2] == dropoff_time[c2] - parameters["request_time"][c2])
@addConstraint(model, _tmp3[c1,c2] == _tmp1[c1,c2] - _tmp2[c1,c2])
@addConstraint(model, _tmp4[c1,c2] == pos_tmp4[c1,c2] + neg_tmp4[c1,c2])
@addConstraint(model, _tmp3[c1,c2] == pos_tmp4[c1,c2] - neg_tmp4[c1,c2])
@addConstraint(model, _value >= _tmp4[c1,c2])
end
end