Re: Demo: Modelling Cost of Travel Paths Between Towns
Date: 8 Nov 2004 19:28:16 -0800
Message-ID: <4b45d3ad.0411081928.6a6907a4_at_posting.google.com>
> > // Create directional verb "to" > > Documentation error. you actually created the verb "goto"
Thanks.
> > CREATE2 c.goto = d; > > CREATE2 d.to = c; > > Compile error. no such method as "to"
Thanks! for spotting the semantic (but not syntatic) error. I originally created the script using "to" instead of "goto", but later realized that since the db already has the preposition "to", I would need to use the expression (%.cls=verb & %.name=to) in order to distinguish them making the script longer. During the conversion from "to" to "goto" I made the above significant error.
> > // Create it cost 1.00 to go from town a to town b > > // on monday between 00:00 and 24:00 > > CREATE2 (a.goto=b).weekday = +monday; > > weird operators...is there such a thing as a negative monday?
The + indicates that if monday does not already exist as an instance of the verb (weekday), go ahead and create it. The above script is equivalent to below which doesn't use the "+" sign:
CREATE2 *; // aka it
CREATE2 it.name = monday; // short cut to relating to each symbol CREATE2 it.cls = weekday; CREATE2 (a.goto=b).weekday = monday; // or "(a.goto=b).weekday = it;"
I am open to suggestions for improving XDb2's scripting language.
> Now that you have a design, what problems do you think you can solve > with it? (You are not really so uninformed as to suggest this might solve > the travelling salesman problem, are you?)
I assumed that people would understand the example only represents the things needed in a db to calculate best path and not the algorithms to do so. However I believe I could code the algorithm. Are you saying that no one has solved this type of problem with RM thus far?
Below is the updated script:
CREATE2 *town.cls = thing; CREATE2 *a.cls = town; CREATE2 *b.cls = town; CREATE2 *c.cls = town; CREATE2 *d.cls = town;
// Create uni-directional verb "goto"
// which leads to lower level (aka creature)
CREATE2 *goto.cls = verb;
CREATE2 goto.vbType = cr;
// Create a square shaped graph
// 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.goto = 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)
CREATE2 *start.cls = thing;
// Create end time of day (exclusive)
CREATE2 *end.cls = thing;
// Create costs
CREATE2 *cost.cls = thing;
// Create it cost 1.00 to go from town a to town b
// 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;
// Create it cost 1.56 to go from town b to town a
// on tuesday between 08:00 and 17:00
CREATE2 (b.goto=a).weekday = +tuesday; CREATE2 ((b.goto=a).weekday=tuesday).start = +08:00; CREATE2 (((b.goto=a).weekday=tuesday).start=08:00).end = +17:00; CREATE2 ((((b.goto=a).weekday=tuesday).start=08:00).end=17:00).cost =+1.56;
// Create it cost 2.30 to go from town b to town c
// on wednesday between 09:00 and 15:00
CREATE2 (b.goto=c).weekday = +wednesday; CREATE2 ((b.goto=c).weekday=wednesday).start = +09:00; CREATE2 (((b.goto=c).weekday=wednesday).start=09:00).end = +15:00; CREATE2 ((((b.goto=c).weekday=wednesday).start=09:00).end=15:00).cost= +2.30;
// Create it cost 3.16 to go from town c to town b
// on thursday between 10:00 and 14:00
CREATE2 (c.goto=b).weekday = +thursday; CREATE2 ((c.goto=b).weekday=thursday).start = +10:00; CREATE2 (((c.goto=b).weekday=thursday).start=10:00).end = +14:00; CREATE2 ((((c.goto=b).weekday=thursday).start=10:00).end=14:00).cost =+3.16; Received on Tue Nov 09 2004 - 04:28:16 CET