A Different Scheduling Problem

View: New views
18 Messages — Rating Filter:   Alert me  

A Different Scheduling Problem

by Dr Bill Kelly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've enjoyed the thread started by David Adams on detecting overlapping events.

A common request we get from clients is "Can you find me the next available slot for an 15/30/45 minute appointment?"

What approaches do you take to find something that technically is not there?

Cheers,

Bill
---------------------------------------------------------------
Dr Bill Kelly
DoctorWare - Developers of SmartRooms
Medical Practice Management Software for Macintosh & Windows
PO Box 2126, East Ivanhoe VIC Australia 3079
Intl phone: 61-3-9499-4622  fax: 61-3-9497-3434
email: bkelly@...
---------------------------------------------------------------

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Bill Weale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This an app just waiting to use svg graphics...

8-)

Bill


On Nov 12, 2009, at 7:26 PM, Bill Kelly wrote:

> Hi,
>
> I've enjoyed the thread started by David Adams on detecting  
> overlapping events.
>
> A common request we get from clients is "Can you find me the next  
> available slot for an 15/30/45 minute appointment?"
>
> What approaches do you take to find something that technically is  
> not there?
>
> Cheers,
>
> Bill

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Robert McKeever :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dr. Bill:

We do just that for our physicians. We have a scheduling grid (mow in  
SVG). Each row is a specific doctor and day. Columns define time  
blocks, usually 15 minutes. Each cell has a background color (bookable  
time vs. non-bookable time) (bookable time will also carry the type of  
time and location (office 1, office 2, hospital 1, hospital 2, etc).  
Booked appointments have contrasting colors. The colors for the lines  
are kept in 2 dimensional arrays, and it is quite easy to scan for the  
presence of 1, 2, 3, or more as needed, consecutive background colored  
cells of the right type.

On Nov 12, 2009, at 4:26 PM, Bill Kelly wrote:

> Hi,
>
> I've enjoyed the thread started by David Adams on detecting  
> overlapping events.
>
> A common request we get from clients is "Can you find me the next  
> available slot for an 15/30/45 minute appointment?"
>
> What approaches do you take to find something that technically is  
> not there?
>
> Cheers,
>
> Bill
> ---------------------------------------------------------------
> Dr Bill Kelly
> DoctorWare - Developers of SmartRooms
> Medical Practice Management Software for Macintosh & Windows
> PO Box 2126, East Ivanhoe VIC Australia 3079
> Intl phone: 61-3-9499-4622  fax: 61-3-9497-3434
> email: bkelly@...
> ---------------------------------------------------------------
>
> **********************************************************************
> Get up to $600 to spend on Amazon.com
> this holiday season - http://www.4d.com/serverpromo.html
>
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4D.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> **********************************************************************

_________________________________________
Bob McKeever                      http://www.mswl.com
McKeever's Software Wizardry
Maple Ridge, B.C.
bobmckeever@...



**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by David Adams-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 13, 2009 at 11:26 AM, Bill Kelly <bkelly@...> wrote:
> Hi,
>
> I've enjoyed the thread started by David Adams on detecting overlapping events.
>
> A common request we get from clients is "Can you find me the next available slot for an 15/30/45 minute appointment?"
>
> What approaches do you take to find something that technically is not there?

This sounds like a perfect example of when treating times as
chunks/resources would be a perfect match. So, you might end up with a
record for 8:00-8:15, another for 8:15-8:30, and so on. If you have
multiple rooms (chairs...or whatever they're called in your
environment), then you'd have a record for each room and time slot.
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Julio Carneiro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did I understand that right?
Are you suggesting that in cases where the 'allocation slot' is fixed  
you'd pre-create records for all time slots? (e.g. booking medical  
appointments in 15/30 min. slots)
And you'd search for an empty 'slot' record?

I am afraid that would not work. For one, you would not be able to  
book appointments for anything but multiples of your slot length. I  
can assure you, we will need to have flexibility to book/block time  
slots of any length.
Besides that, how far along in the future would you create those empty  
slots?

In our case (for a medical appointments app) we do a brute force  
search within a period specified by the user. That is because we allow  
a different configuration of each day of the week and even a special  
configuration for certain dates. Thus we need to build a day's  
'calendar' in arrays, with slots and appointments for that specific  
date, then search those arrays for an opening of the requested length.  
That loops thru each day till an opening is found or not.

Now let me tell you, users rarely use that function.... they prefer to  
navigate the calendar view and look for opening visually.
LIke McKeever suggested, colour coding you calendar view helps users  
spot those opening easily.

julio

On Nov 13, 2009, at 12:59 AM, David Adams wrote:

> On Fri, Nov 13, 2009 at 11:26 AM, Bill Kelly  
> <bkelly@...> wrote:
>> Hi,
>>
>> I've enjoyed the thread started by David Adams on detecting  
>> overlapping events.
>>
>> A common request we get from clients is "Can you find me the next  
>> available slot for an 15/30/45 minute appointment?"
>>
>> What approaches do you take to find something that technically is  
>> not there?
>
> This sounds like a perfect example of when treating times as
> chunks/resources would be a perfect match. So, you might end up with a
> record for 8:00-8:15, another for 8:15-8:30, and so on. If you have
> multiple rooms (chairs...or whatever they're called in your
> environment), then you'd have a record for each room and time slot.

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by David Adams-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 13, 2009 at 3:37 PM, Julio Carneiro <jjfourd@...> wrote:
> Did I understand that right?
> Are you suggesting that in cases where the 'allocation slot' is fixed you'd
> pre-create records for all time slots? (e.g. booking medical appointments in
> 15/30 min. slots)
> And you'd search for an empty 'slot' record?

I've never done it and perhaps misunderstood the idea. If I got the
idea right then, yes, you've got a record for each slot. The slots
need to fit to your real-world level of granularity. If you break
slots on 5 minute increments and cover 10 hours a day 5 days a week,
that gives you 1,000 records per room, per week. From there, an event
may occupy several of the five minute slots. So, if the meeting is
from 8:00-9:00 it takes up the 20 records within that period.

Again, I haven't tried this out and can't say how well it works. It's
not an ideal match for my problem so I haven't pursued it.

> I am afraid that would not work. For one, you would not be able to book
> appointments for anything but multiples of your slot length.
Correct.

> I can assure you, we will need to have flexibility to book/block time slots of any
> length.
That depends on the organization - some places don't need 1 minute
granularity, or what have you.

> Besides that, how far along in the future would you create those empty
> slots?

No idea - I haven't done it.

> In our case (for a medical appointments app) we do a brute force search
> within a period specified by the user. That is because we allow a different
> configuration of each day of the week and even a special configuration for
> certain dates. Thus we need to build a day's 'calendar' in arrays, with
> slots and appointments for that specific date, then search those arrays for
> an opening of the requested length. That loops thru each day till an opening
> is found or not.

Yeah, that sounds like a sensible approach.

> Now let me tell you, users rarely use that function.... they prefer to
> navigate the calendar view and look for opening visually.

I'm really looking foward to making some more progress with hmCal - it
seems great for this sort of thing. I'm imagining showing, for
example, a room and all of its appointments. It there are conflicts -
they'll show up without any fuss at all.
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Parent Message unknown Re: A Different Scheduling Problem

by Dr Bill Kelly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We currently use hmCal so the graphical representation of the schedule is already handled. Users can't be bothered to scroll forward 3 or 6 months into the future to view the schedule but want a button to tell the program to go out and find the hole for them.

Cheers,

Bill
---------------------------------------------------------------
Dr Bill Kelly
DoctorWare - Developers of SmartRooms
Medical Practice Management Software for Macintosh & Windows
PO Box 2126, East Ivanhoe VIC Australia 3079
Intl phone: 61-3-9499-4622  fax: 61-3-9497-3434
email: bkelly@...
---------------------------------------------------------------

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Parent Message unknown Re: A Different Scheduling Problem

by Daniel N. Solenthaler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have made the same experience: although I have created a dialog to  
find free slots in the agenda, the users don't really use it. They  
prefer to look for themselves.

Anyhow, I find working with timestamps helpful. I have stored a start  
timestamp and an end timestamp for each appointment in the database.  
This makes it easy to find out, whether there is already an  
appointment at a given timeslot:

        QUERY SELECTION([AGE_APPOINTMENTS];[AGE_APPOINTMENTS]ENDSTAMP<=
$Startstamp;*)
        QUERY SELECTION([AGE_APPOINTMENTS]; | ;[AGE_APPOINTMENTS]STARTSTAMP>=
$Endstamp)
       
Finding the next free time slot is basically a loop, which ends as  
soon as the above query returns an empty selection.

Regards
Daniel
daniel@...


Am 13.11.2009 um 09:00 schrieb 4d_tech-request@...:

> Now let me tell you, users rarely use that function.... they prefer to
> navigate the calendar view and look for opening visually.
> LIke McKeever suggested, colour coding you calendar view helps users
> spot those opening easily.

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Rob Laveaux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 13 nov 2009, at 01:26, Bill Kelly wrote:

> A common request we get from clients is "Can you find me the next  
> available slot for an 15/30/45 minute appointment?"

Hi Bill,

I have a lot of experience with automated scheduling.

I once developed a system that was used for nuclear medicine. They had  
to schedule examinations consisting of several steps with set  
intervals between them. Each step was dependent on the availability of  
personnel, rooms and equipment. There were many parameters that could  
be set. With a click of a button, the system would automatically  
schedule such an examination.

The trick is that you need to build a matrix of the availability per  
day of each resource. You can then compare the various resources and  
check for a timeframe where they are all available. Such a matrix can  
be represented using a text array, where each item holds a  
representation of the schedule for that day. So if you use a unit of 5  
minutes, then each array item would consist of 288 characters. I would  
mark the available times with "0" and non-available times with "1".  
You can also use other characters for different meanings. When you  
then need to schedule an examination of 30 minutes, you just have to  
look for six consecutive zeros "000000". When you need to schedule  
multiple resources, you just check them in parallel. Of course it gets  
more difficult when the interval between events is interdependent and  
when you can not find any opportunity that fits. In such cases you  
need to program more intelligence. But that's what I did for the  
system I worked on.

I hope this helps you further.

PS If you need further assistance with this, I'm available for  
contract work :-)

- Rob Laveaux

--------------------------------------------------------
Pluggers Software
Bleriotlaan 62
2497 BM  Den Haag
The Netherlands

Email: rob.laveaux@...
Website: http://www.pluggers.nl

--------------------------------------------------------



**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by David Adams-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Nov 13, 2009 at 9:35 PM, Rob Laveaux <rob.laveaux@...> wrote:

> The trick is that you need to build a matrix of the availability per day of
> each resource. You can then compare the various resources and check for a
> timeframe where they are all available. Such a matrix can be represented
> using a text array, where each item holds a representation of the schedule
> for that day. So if you use a unit of 5 minutes, then each array item would
> consist of 288 characters. I would mark the available times with "0" and
> non-available times with "1". You can also use other characters for
> different meanings. When you then need to schedule an examination of 30
> minutes, you just have to look for six consecutive zeros "000000". When you
> need to schedule multiple resources, you just check them in parallel. Of
> course it gets more difficult when the interval between events is
> interdependent and when you can not find any opportunity that fits. In such
> cases you need to program more intelligence. But that's what I did for the
> system I worked on.

I was thinking about something along these lines earlier. Rather than
building out the time grid (matrix) as records, you could have a text
or BLOB that stored the data. As an example:

* What you describe above only stored a bit differently.
* A series of bits - one per schedule block - stored in a BLOB or
series of numbers.
* A series of bytes - one per schedule block - stored in a BLOB or
text. (I'm thinking 2004.)

It also crossed my mind that if you have a room that may have only one
event in any slot, then you could have a structure that stores either
the ID of the event or, for example, 000000. In this case, your
structure could be the same length for any room (1,728 bytes),
regardless of how many slots or open or not. Given that the ID length
is always made the same length, you can quickly test any period.

I'm not writing very clearly - I'm just talking about a simple,
fixed-length structure that makes it easy and quick to get to any
particular item and check if its unused (000000) or used (6-digit ID,
in this example.) In this case, It's much like your 0/1 for occupied
system but the ID of the resource is stored directly - hence the
longer data. For that matter, you could store both a single byte for
busy/free and then the IDs elsewhere. After working with XML a lot, it
can be a relief to work with fixed-length data for a change ;-) I
think folk often forget how incredibly fast it can be to access data
when you can calculate it's exact position and go and grab it - no
searches, linear scans, or fancy tree structures to navigate.

   Start = (Item Number - 1) * Length
   End =  Start + Length

Pardon any off-by one there...I should never write code off the top of my head.

I was having a swim and that's as far as I got with thinking about it.
As you've already gone down this road successfully before, comments
would be welcome. I don't actually need such a system for my current
system but I figure I might as well think about scheduling problems
and solutions now that they're on my mind...
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Julio Carneiro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A Boolean array would probably be your best shot.
Boolean arrays are optimized in 4D. Internally a Boolean array is a  
bitmap, that is, each item in a Boolean occupies 1 bit.

Thus if you use 1 boolean per minute, that will correspond to 1440  
bits or 180 character per day. 100 days, roughly a tad over 3 months  
worth will use only 18k in memory.
If you store that as a compressed blob, it should use very little disk  
space, thus save/load operations are very fast. If you lower the  
granularity to say 5mins, or 10 mins, you'll decrease the space  
required 5-fold, or 10-fold.

Using a single bit for each minute of a resource has the advantage  
that checking for a conflict is just a matter of testing if a bit is  
on/off. Same if you're looking for an open spot, just scan the array  
for a clear bit.

In your case where you're looking for more than a yes/no response to a  
conflict, and want to identify the actual conflicting event, a boolean  
array is enough. IF you find a conflict, an on bit, you can easily get  
the corresponding event record via its date/time signature (you can  
calculate that from the bit position in the array).
In terms of speed and efficiency I think that is better than store the  
ID or 000000 on the array.

And that leads to an idea: why not combine my suggestion of treating  
anything related to an Event as a 'resource' (room, lead, attendee,  
computer, projector, microscope,...), and this 'availability bitmap'  
idea?
Then you'd have a 'resource availability bitmap' for each resource.  
Finding conflicts across multiple 'resources' would be a matter of  
combining those bitmaps.

Now, you may ask, how is that bitmap approach different than say a  
cluster index? or 4D's own internal 'bitmap' used to find open spaces  
in the datafile? Well, it is not!

That should give you a whole new lot of tried and proved algorithms  
that deal with bitmaps, boolean sets, and whatnots.

(just mumbling and thinking our loud here, I have not done any of  
that. like you I had time to think during a long swim :-))

julio


**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Christian Sakowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bill,

we plan to introduce such a complex "search" in hmCal 3.x. I mean complex, because hmCal does support recurrence appointments. So maybe this is a complex calculation. I thought you can do this with the command "hmCal_GET RECURRENCE INFO" and loop through the dates. But we plan to introduce a convenient way to look for free time slots.

For other advices and wishes, you can contact me privatly.

hmCal 3.0 code is frozen and will be published together with 4D v11.5.
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
Christian.sakowski@...
iChat/AIM: SakowskiF
ICQ: 4thDimension (267537916)
Tel: 040/52 10 59-23



Am 13.11.2009 um 01:26 schrieb Bill Kelly:

> Hi,
>
> I've enjoyed the thread started by David Adams on detecting overlapping events.
>
> A common request we get from clients is "Can you find me the next available slot for an 15/30/45 minute appointment?"
>
> What approaches do you take to find something that technically is not there?
>
> Cheers,
>
> Bill
> ---------------------------------------------------------------
> Dr Bill Kelly
> DoctorWare - Developers of SmartRooms
> Medical Practice Management Software for Macintosh & Windows
> PO Box 2126, East Ivanhoe VIC Australia 3079
> Intl phone: 61-3-9499-4622  fax: 61-3-9497-3434
> email: bkelly@...
> ---------------------------------------------------------------
>
> **********************************************************************
> Get up to $600 to spend on Amazon.com
> this holiday season - http://www.4d.com/serverpromo.html
>
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4D.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> **********************************************************************
>

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html


4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Doug Hall-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Not meaning to troll, here, but does 4D STILL not support timestamps
natively? OMG. Big hole, 4D. Big, freaking, giant gaping hole. Shame
on you, 4D Inc.! The '92 SQL standard declares a date+time+timezone
field called timestamp. Umm, let's see that was a standard set 17
years ago. Personally, I don't see the point of calling it "standard"
query language if it doesn't truly meet some kind of STANDARD. That
wreaks of false advertising. But whatever you want to call it, just
quit making your users jump through hoops to manage time data!

Opinionated, as always,
Doug
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Jody Bevan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This all sounds great. Now how are you storing this information?

Add in that there are 100 people (or more) that are looking to  
schedule. How are you handling the locking out of a slot while someone  
indicates they want a selection of times / dates / resources? This all  
needs to be handled in real time. Each second (actually less than  
that) there are changes occurring.

Jody


In Nov, 2009, Julio Carneiro and others wrote:

> A Boolean array would probably be your best shot.
> Boolean arrays are optimized in 4D. Internally a Boolean array is a  
> bitmap, that is, each item in a Boolean occupies 1 bit.
>
> Thus if you use 1 boolean per minute, that will correspond to 1440  
> bits or 180 character per day. 100 days, roughly a tad over 3 months  
> worth will use only 18k in memory.
> If you store that as a compressed blob, it should use very little  
> disk space, thus save/load operations are very fast. If you lower  
> the granularity to say 5mins, or 10 mins, you'll decrease the space  
> required 5-fold, or 10-fold.
>
> Using a single bit for each minute of a resource has the advantage  
> that checking for a conflict is just a matter of testing if a bit is  
> on/off. Same if you're looking for an open spot, just scan the array  
> for a clear bit.
>
> In your case where you're looking for more than a yes/no response to  
> a conflict, and want to identify the actual conflicting event, a  
> boolean array is enough. IF you find a conflict, an on bit, you can  
> easily get the corresponding event record via its date/time  
> signature (you can calculate that from the bit position in the array).
> In terms of speed and efficiency I think that is better than store  
> the ID or 000000 on the array.
>
> And that leads to an idea: why not combine my suggestion of treating  
> anything related to an Event as a 'resource' (room, lead, attendee,  
> computer, projector, microscope,...), and this 'availability bitmap'  
> idea?
> Then you'd have a 'resource availability bitmap' for each resource.  
> Finding conflicts across multiple 'resources' would be a matter of  
> combining those bitmaps.
>
> Now, you may ask, how is that bitmap approach different than say a  
> cluster index? or 4D's own internal 'bitmap' used to find open  
> spaces in the datafile? Well, it is not!
>
> That should give you a whole new lot of tried and proved algorithms  
> that deal with bitmaps, boolean sets, and whatnots.
>
> (just mumbling and thinking our loud here, I have not done any of  
> that. like you I had time to think during a long swim :-))
>
> julio
>

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Douglas Davis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

News Flash:  4D has suddenly put in gear a quick change.

The new "4D v11 almost SQL" will be hitting the markets very soon.  Thanks
so much for bringing this to our attention!

The very Sarcastic,
Doug




**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Julio Carneiro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good point... (see the caveat at the end of my post).

Controlling access to the bitmap would be a nightmare when you have a  
lot of users hitting the scheduler :-(
I guess that approach does not sound clever anymore :-( glad that is  
not the way I do it :-)

julio

On Nov 13, 2009, at 2:28 PM, Jody Bevan wrote:

> This all sounds great. Now how are you storing this information?
>
> Add in that there are 100 people (or more) that are looking to  
> schedule. How are you handling the locking out of a slot while  
> someone indicates they want a selection of times / dates /  
> resources? This all needs to be handled in real time. Each second  
> (actually less than that) there are changes occurring.
>
> Jody
>
>
> In Nov, 2009, Julio Carneiro and others wrote:
>
>> A Boolean array would probably be your best shot.
>> Boolean arrays are optimized in 4D. Internally a Boolean array is a  
>> bitmap, that is, each item in a Boolean occupies 1 bit.
>>
>> Thus if you use 1 boolean per minute, that will correspond to 1440  
>> bits or 180 character per day. 100 days, roughly a tad over 3  
>> months worth will use only 18k in memory.
>> If you store that as a compressed blob, it should use very little  
>> disk space, thus save/load operations are very fast. If you lower  
>> the granularity to say 5mins, or 10 mins, you'll decrease the space  
>> required 5-fold, or 10-fold.
>>
>> Using a single bit for each minute of a resource has the advantage  
>> that checking for a conflict is just a matter of testing if a bit  
>> is on/off. Same if you're looking for an open spot, just scan the  
>> array for a clear bit.
>>
>> In your case where you're looking for more than a yes/no response  
>> to a conflict, and want to identify the actual conflicting event, a  
>> boolean array is enough. IF you find a conflict, an on bit, you can  
>> easily get the corresponding event record via its date/time  
>> signature (you can calculate that from the bit position in the  
>> array).
>> In terms of speed and efficiency I think that is better than store  
>> the ID or 000000 on the array.
>>
>> And that leads to an idea: why not combine my suggestion of  
>> treating anything related to an Event as a 'resource' (room, lead,  
>> attendee, computer, projector, microscope,...), and this  
>> 'availability bitmap' idea?
>> Then you'd have a 'resource availability bitmap' for each resource.  
>> Finding conflicts across multiple 'resources' would be a matter of  
>> combining those bitmaps.
>>
>> Now, you may ask, how is that bitmap approach different than say a  
>> cluster index? or 4D's own internal 'bitmap' used to find open  
>> spaces in the datafile? Well, it is not!
>>
>> That should give you a whole new lot of tried and proved algorithms  
>> that deal with bitmaps, boolean sets, and whatnots.
>>
>> (just mumbling and thinking our loud here, I have not done any of  
>> that. like you I had time to think during a long swim :-))
>>
>> julio
>>
>
> **********************************************************************
> Get up to $600 to spend on Amazon.comthis holiday season - http://www.4d.com/serverpromo.html
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4D.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> **********************************************************************

**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Douglas von Roeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>From a previous life - "Lieutenant, there are no problems. Just challenges
and opportunities."

I think of this in terms of loose coupling, queueing, resource locking, and
notification. 4D has all of the tools to do this.

Loose coupling - on the client side, set up a paused, slave process. When
you want to check the availability of a time slot, send a message to the
process (I call mine "Gopher"). Gopher will poll the server and, when
appropriate, send an interprocess message back to the calling process. My
handing off the client-server communication to Gopher, the process that
displays the scheduling window can perform other tasks.

Queueing - Gopher sends its request to the server that builds a queue of
requests according to the resource that's desired. (There are a "veritable
plethora" of ways to invoke code on the server, right?). 2D arrays are your
friend here (multi-dimensional would be nicer!) because you can assign an
array to a resource and then plop the request (or a reference to the
request) in the array element. You can create one or many processes to read
the contents of the arrays and do the scheduling there.

Resource locking - you can do this by ensuring that only one server side
process accesses a resource and its queue or you can use a local semaphore
on the server machine.

Notification - depends on the mechanism you use to communicate between
client and server. If you're using Set and Get process variable, you have to
loop around on the client. If you're using web services, no polling is
necessary. If you use your own TCP/IP system, you'll have to Loop...Until

I built a real time telephony/call monitoring system a few years ago and one
of the points that was driven home to me was that there are many, many ways
to skin the cat.

--
Douglas von Roeder



On Fri, Nov 13, 2009 at 10:35 AM, Julio Carneiro <jjfourd@...> wrote:

> Good point... (see the caveat at the end of my post).
>
> Controlling access to the bitmap would be a nightmare when you have a lot
> of users hitting the scheduler :-(
> I guess that approach does not sound clever anymore :-( glad that is not
> the way I do it :-)
>
> julio
>
>
> On Nov 13, 2009, at 2:28 PM, Jody Bevan wrote:
>
>  This all sounds great. Now how are you storing this information?
>>
>> Add in that there are 100 people (or more) that are looking to schedule.
>> How are you handling the locking out of a slot while someone indicates they
>> want a selection of times / dates / resources? This all needs to be handled
>> in real time. Each second (actually less than that) there are changes
>> occurring.
>>
>> Jody
>>
>>
>> In Nov, 2009, Julio Carneiro and others wrote:
>>
>>  A Boolean array would probably be your best shot.
>>> Boolean arrays are optimized in 4D. Internally a Boolean array is a
>>> bitmap, that is, each item in a Boolean occupies 1 bit.
>>>
>>> Thus if you use 1 boolean per minute, that will correspond to 1440 bits
>>> or 180 character per day. 100 days, roughly a tad over 3 months worth will
>>> use only 18k in memory.
>>> If you store that as a compressed blob, it should use very little disk
>>> space, thus save/load operations are very fast. If you lower the granularity
>>> to say 5mins, or 10 mins, you'll decrease the space required 5-fold, or
>>> 10-fold.
>>>
>>> Using a single bit for each minute of a resource has the advantage that
>>> checking for a conflict is just a matter of testing if a bit is on/off. Same
>>> if you're looking for an open spot, just scan the array for a clear bit.
>>>
>>> In your case where you're looking for more than a yes/no response to a
>>> conflict, and want to identify the actual conflicting event, a boolean array
>>> is enough. IF you find a conflict, an on bit, you can easily get the
>>> corresponding event record via its date/time signature (you can calculate
>>> that from the bit position in the array).
>>> In terms of speed and efficiency I think that is better than store the ID
>>> or 000000 on the array.
>>>
>>> And that leads to an idea: why not combine my suggestion of treating
>>> anything related to an Event as a 'resource' (room, lead, attendee,
>>> computer, projector, microscope,...), and this 'availability bitmap' idea?
>>> Then you'd have a 'resource availability bitmap' for each resource.
>>> Finding conflicts across multiple 'resources' would be a matter of combining
>>> those bitmaps.
>>>
>>> Now, you may ask, how is that bitmap approach different than say a
>>> cluster index? or 4D's own internal 'bitmap' used to find open spaces in the
>>> datafile? Well, it is not!
>>>
>>> That should give you a whole new lot of tried and proved algorithms that
>>> deal with bitmaps, boolean sets, and whatnots.
>>>
>>> (just mumbling and thinking our loud here, I have not done any of that.
>>> like you I had time to think during a long swim :-))
>>>
>>> julio
>>>
>>>
>> **********************************************************************
>> Get up to $600 to spend on Amazon.comthis holiday season -
>> http://www.4d.com/serverpromo.html
>>
>> 4D Internet Users Group (4D iNUG)
>> FAQ:  http://lists.4d.com/faqnug.html
>> Archive:  http://lists.4D.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:4D_Tech-Unsubscribe@...
>> **********************************************************************
>>
>
> **********************************************************************
> Get up to $600 to spend on Amazon.comthis holiday season -
> http://www.4d.com/serverpromo.html
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4D.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4D_Tech-Unsubscribe@...
> **********************************************************************
>
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************

Re: A Different Scheduling Problem

by Jim Dorrance :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simple semaphores are also very useful for 'locking' a virtual record,
possibility, anything.



--
Jim Dorrance
jim.dorrance@...
www.4d.dorrance.eu
www.photo.dorrance.eu
**********************************************************************
Get up to $600 to spend on Amazon.com
this holiday season - http://www.4d.com/serverpromo.html
   

4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4D.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4D_Tech-Unsubscribe@...
**********************************************************************