A Transportation Model in OPL
Keywords: main

Next: Bibliography Up: MATISSE: OPL Redesigned as Language Previous: The Typed Polymorphic -Calculus

#
A Transportation Model in OPL

    [01]    enum City ...;
    [02]    enum Product ...;
    [03]    float+ limit = ...;
    [04]
    [05]    struct TableRoutesType
    [06]       { Product p;
    [07]         City o;
    [08]         City d;
    [09]         float+ cost;
    [10]       };
    [11]
    [12]    {TableRoutesType} TableRoutes = ...;
    [13]
    [14]    struct Connection
    [15]       { City o;
    [16]         City d;
    [17]       };
    [18]
    [19]    struct Route
    [20]       { Product p;
    [21]         Connection e;
    [22]       };
    [23]
    [24]    {Route} Routes = { < p,<o,d> > | <p,o,d,c> in TableRoutes };
    [25]
    [26]    {Connection} Connections = { c | <p,c> in Routes };
    [27]
    [28]    struct Supply
    [29]       { Product p;
    [30]         City o;
    [31]       };
    [32]
    [33]    {Supply} Supplies = { <p,c.o> | <p,c> in Routes };
    [34]
    [35]    float+ supply[Supplies] = ...;
    [36]
    [37]    struct Customer
    [38]       { Product p;
    [39]         City d;
    [40]       };
    [41]
    [42]    {Customer} Customers = { <p,c.d> | <p,c> in Routes };
    [43]
    [44]    float+ demand[Customers] = ...;
    [45]
    [46]    float+ cost[Routes];
    [47]
    [48]    initialize
    [49]       { forall( <p,o,d,c> in TableRoutes)
    [50]            cost[< p,<o,d> >] = c;
    [51]       };
    [52]
    [53]    {City} orig[p in Product] = { c.o | <p,c> in Routes };
    [54]    {City} dest[p in Product] = { c.d | <p,c> in Routes };
    [55]
    [56]    {Connection} CP[p in Product] = { c | <p,c> in Routes };
    [57]
    [58]    assert
    [59]       forall(p in Product)
    [60]         sum(o in orig[p]) supply[<p,o>] = sum(d in dest[p]) demand[<p,d>];
    [61]
    [62]    var float+ trans[Routes];
    [63]
    [64]    minimize
    [65]       sum(l in Routes) cost[l] * trans[l]
    [66]    subject to
    [67]       {
    [68]         forall(p in Product, o in orig[p])
    [69]            sum(<o,d> in CP[p]) trans[< p,<o,d> >] <= supply[<p,o>];
    [70]
    [71]         forall(p in Product, d in dest[p])
    [72]            sum(<o,d> in CP[p]) trans[< p,<o,d> >] >= demand[<p,d>];
    [73]
    [74]         forall(c in Connections)
    [75]            sum(<p,c> in Routes) trans[<p,c>] <= limit;
    [77]       };