dbTalk Databases Forums  

Demo: Modelling Cost of Travel Paths Between Towns

comp.databases.object comp.databases.object


Discuss Demo: Modelling Cost of Travel Paths Between Towns in the comp.databases.object forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-09-2004 , 12:43 AM






Quote:
There is no such time as 24:00 Hrs; read ISO-8601.
You are correct (but XDb2 has nothing to do with ISO-8601).

Quote:
... SQL Script ....
Thanks for posting the script to model the data in RM. Below is XDb2's
script to model it in approximately the same manner. A view of the
data in a tree and grid is shown at www.xdb2.com/Example/Ex112b.asp

// Create base classes/verbs
CREATE2 *trip.cls = thing;

CREATE2 *city.cls = thing;
CREATE2 *a.cls = city;
CREATE2 *b.cls = city;
CREATE2 *c.cls = city;
CREATE2 *d.cls = city;

CREATE2 *src.cls = verb;
CREATE2 *dest.cls = verb;
CREATE2 *weekday.cls = thing;
CREATE2 *start.cls = thing;
CREATE2 *end.cls = thing;
CREATE2 *cost.cls = thing;

// Create trip from a to b
// on monday from 00:00 to 24:00 costs 1.00
CREATE2 *;
CREATE2 it.cls = trip;
CREATE2 it.src = a;
CREATE2 it.dest = b;
CREATE2 it.weekday = +monday;
CREATE2 it.start = +00:00; // inclusive
CREATE2 it.end = +24:00; // exclusive
CREATE2 it.cost = +1.00

// Create trip from b to a
// on monday from 00:00 to 24:00 costs 1.00
CREATE2 *;
CREATE2 it.cls = trip;
CREATE2 it.src = b;
CREATE2 it.dest = a;
CREATE2 it.weekday = +monday;
CREATE2 it.start = +00:00; // inclusive
CREATE2 it.end = +24:00; // exclusive
CREATE2 it.cost = +1.00;


Reply With Quote
  #12  
Old   
Jonathan Leffler
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-09-2004 , 01:16 AM






Neo wrote:
Quote:
There is no such time as 24:00 Hrs; read ISO-8601.

You are correct
Really - who read ISO 8601?

Section 5.3 (of FDIS for 2000 edition): Time of the Day

As this International Standard is based on the 24-hour timekeeping
system that is now in common use, hours are represented by two digits
from [00] to [24], ...

The representation of the hour by [24] is only allowed to indicate
midnight, see 5.3.2.

5.3.2 Midnight
The complete representations in basic and extended format for
midnight, in accordance with 5.3.1, shall be expressed
in either of the two following ways:

Basic format Extended format
a) 000000 00:00:00 (the beginning of a day);
b) 240000 24:00:00 (the end of a day).

The wording in the previous edition (ISO 8601:1988) is equivalent.

--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler (AT) earthlink (DOT) net, jleffler (AT) us (DOT) ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/


Reply With Quote
  #13  
Old   
Laconic2
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-09-2004 , 07:08 AM




"--CELKO--" <jcelko212 (AT) earthlink (DOT) net> wrote


Quote:
That gets all the (travel_cost = 1) edges in the graph. Next, use
Warshall's algorithm to fill in travel costs on ('c', 'a'), ('d', 'b')
and so forth. This will work for any adjacency list model. I would
do the matrix multiplications in a host language like FORTRAN, C or
Pascal, but I can do it in pure SQL if I have to (see that section in
SQL FOR SMARTIES).
Hey, don't forget good old BASIC!!!! I thought that this:

LET MATRIXC = MATRIXA * MATRIXB

was one of the coolest features of Dartmouth Basic!

But I suppose that most implementations of BASIC don't have this feature.





Reply With Quote
  #14  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-09-2004 , 11:39 AM



Quote:
There is no such time as 24:00 Hrs; read ISO-8601.
You are correct ...
Really - who read ISO 8601?
I didn't. And yes I assumed Mr Celko was correct. Regardless of
what is written, it seems that a field allowing time continums greater
than a day should not have values such as July 4th 2000, 24:00 but the
24:00 format should be ok if it only applies to a single day (ie
Monday, Tuesday, ...).


Reply With Quote
  #15  
Old   
Ja Lar
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-09-2004 , 11:43 AM




"Jonathan Leffler" <jleffler (AT) earthlink (DOT) net> ....
Quote:
--CELCO-- wrote ...
Neo wrote:
There is no such time as 24:00 Hrs; read ISO-8601.

You are correct

Really - who read ISO 8601?
Section 5.3 (of FDIS for 2000 edition): Time of the Day
<snip>
LOL. Nice double-catch :-)




Reply With Quote
  #16  
Old   
Neo
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-10-2004 , 01:54 PM



Quote:
There is no such time as 24:00 Hrs; read ISO-8601.

You are correct

Really - who read ISO 8601?
Section 5.3 (of FDIS for 2000 edition): Time of the Day

LOL. Nice double-catch :-)
Upon further reflection, while not taking away from the apparent fact
(I haven't verified it) that ISO-8601 mentions the existance of 24:00,
there is no 24th hr in a day and therefore ISO-8601 is wrong! The time
in a day can be described by t, where 0:00 <= t < 24:00, and does not
include 24:00.


Reply With Quote
  #17  
Old   
Ed prochak
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-10-2004 , 02:03 PM



neo55592 (AT) hotmail (DOT) com (Neo) wrote in message news:<4b45d3ad.0411081928.6a6907a4 (AT) posting (DOT) google.com>...
Quote:
Incomplete problem description.
What is the costs for travel on other days?

In order to keep the example simple, the script only showed the cost
of travel between two towns (a to b) in one direction during a
specific day of the week (monday), during a specific time period
(00:00 to 24:00). The updated script at the end has 4 such entries and
should allow one to deduce how to enter additional ones. If you or the
original problem poster would like to present more representative
data, I can enter it.
I thought YOU were the Original poster, at least that's how it looks
in google.

[]
Quote:
Actually all the so-called paths are unidirectional.
You never created a bidirectional "goto" verb.

Didn't need to create a bi-directional verb because two opposite
uni-directionals paths form a bi-directional path as in:
CREATE2 a.goto = b;
CREATE2 b.goto = a;
Understood, I just wanted to make sure others saw that clearly.
Quote:
If I had created a bi-directional verb, it would be difficult to
specify a one way street and different cost/period for each
uni-direction.
Again, I understood this. I am just making sure misused terms do not
confuse other readers.

Quote:
// 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.
You still did not answer the question about signed numbers. How does
the language distinquish between the operation or changing the value
to +1 from the operation of adding a new instance with the value 1.

Quote:
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?
Well, given your reputation in this group I almost expected you to
claim Xdb1 could solve this in something shorter than the brute force
exhaustive search.

Matching that model in a Relational data model is easy enough. (Joe
Celko already posted a SQL model.)

I guess I'm asking: Is there is a point to this thread?

Ed


Reply With Quote
  #18  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-10-2004 , 03:43 PM



neo55592 (AT) hotmail (DOT) com (Neo) wrote:

Quote:
There is no such time as 24:00 Hrs; read ISO-8601.

You are correct

Really - who read ISO 8601?
Section 5.3 (of FDIS for 2000 edition): Time of the Day

LOL. Nice double-catch :-)

Upon further reflection, while not taking away from the apparent fact
(I haven't verified it) that ISO-8601 mentions the existance of 24:00,
there is no 24th hr in a day and therefore ISO-8601 is wrong! The time
in a day can be described by t, where 0:00 <= t < 24:00, and does not
include 24:00.
It can be, but that does not mean it has to be. Besides, what
day does not have twenty-four hours?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #19  
Old   
Ja Lar
 
Posts: n/a

Default OT: Demo: Modelling Cost of Travel Paths Between Towns - 11-10-2004 , 04:36 PM




"Neo" <neo55592 (AT) hotmail (DOT) com> ...

Quote:
Upon further reflection, while not taking away from the apparent fact
(I haven't verified it) that ISO-8601 mentions the existance of 24:00,
there is no 24th hr in a day and therefore ISO-8601 is wrong!
If you haven't verified it, how can you know that ISO-8610 is wrong?
A day certainly has a 24th hour, as a day has 24 hours. The 24th hour begins
just after 23:00.

Quote:
The time
in a day can be described by t, where 0:00 <= t < 24:00, and does not
include 24:00.
Whow, you are a genius. Thank you for pointing out that t<24:00 does not
include 24:00.
Now, what about 12:00 AM and 12:00 PM?







Reply With Quote
  #20  
Old   
Damien
 
Posts: n/a

Default Re: Demo: Modelling Cost of Travel Paths Between Towns - 11-11-2004 , 01:51 AM



Gene Wirchenko <genew (AT) mail (DOT) ocis.net> wrote

Quote:
neo55592 (AT) hotmail (DOT) com (Neo) wrote:

There is no such time as 24:00 Hrs; read ISO-8601.

You are correct

Really - who read ISO 8601?
Section 5.3 (of FDIS for 2000 edition): Time of the Day

LOL. Nice double-catch :-)

Upon further reflection, while not taking away from the apparent fact
(I haven't verified it) that ISO-8601 mentions the existance of 24:00,
there is no 24th hr in a day and therefore ISO-8601 is wrong! The time
in a day can be described by t, where 0:00 <= t < 24:00, and does not
include 24:00.

It can be, but that does not mean it has to be. Besides, what
day does not have twenty-four hours?

Well, of course, if you live in a country where daylight savings
applies, there are two unusual days each year - one of 23 hours, and
one of 25


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.