Demo: Modelling Cost of Travel Paths Between Towns
Date: 7 Nov 2004 18:07:49 -0800
Message-ID: <4b45d3ad.0411071807.4cbd51f0_at_posting.google.com>
www.xdb2.com/Example/Ex112.asp demos how to represent things needed to calculate the cost of traveling between any two towns via multiple paths. The example allows the path between any two towns to be uni or bi-directional. The example allows the specification of travel cost during any time period of each weekday.
More specifically, the example represents the following things: Four towns named a, b, c, d (imagine them forming a square). There are paths from a to b, b to c, c to d and d to a. There are also opposite paths from a to d, d to c, c to b and b to a. In addition, there are two uni-directional cross paths, one from a to c and the second from b to d. The cost of travel from town a to town b on Monday between 00:00 and 24:00 is 1.00.
// Create directional verb "to"
// Create a square shaped graph
// which leads to lower level (aka creature)
CREATE2 *goto.cls = verb;
CREATE2 goto.vbType = cr;
// Note: outer paths are bi-dir
CREATE2 a.goto = b;
CREATE2 b.goto = a;
CREATE2 b.goto = c;
CREATE2 c.goto = b;
CREATE2 c.goto = d;
CREATE2 d.to = c;
CREATE2 d.goto = a;
CREATE2 a.goto = d;
// Note: inner cross paths are uni-dir
CREATE2 a.goto = c;
CREATE2 b.goto = d;
// Create weekdays
CREATE2 *weekday.cls = thing;
// Create start time of day (inclusive)
// Create end time of day (exclusive)
// Create costs
// Create it cost 1.00 to go from town a to town b
CREATE2 *start.cls = thing;
CREATE2 *end.cls = thing;
CREATE2 *cost.cls = thing;
// on monday between 00:00 and 24:00
CREATE2 (a.goto=b).weekday = +monday; CREATE2 ((a.goto=b).weekday=monday).start = +00:00; CREATE2 (((a.goto=b).weekday=monday).start=00:00).end = +24:00; CREATE2 ((((a.goto=b).weekday=monday).start=00:00).end=24:00).cost =+1.00; Received on Mon Nov 08 2004 - 03:07:49 CET