Re: Date query question

2016-11-17 Thread Alexander Burger
Another possibility (which I mentioned initially when we discussed this in IRC)
is to use a 2-dimensional UB-Tree index. This would be the most efficient way,
both in speed and in size (only a single index is required).

   (class +Proj +Macropisobj)
   ...
   (rel sDate (+UB +Aux +Ref +Date) (eDate))
   (rel eDate (+Date))

Then a 'collect' would find the range directly:

   (collect 'sDate '+Proj (list Sdate Sdate) (list Edate Edate))

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: First post

2016-11-17 Thread CILz

Hello,

Thanks for all your suggestions/ideas regarding using PicoLisp DB as a 
kind of graph database. I now have to experiment...


Best,

Eric


Le 17/11/2016 à 23:17, andr...@itship.ch a écrit :

Declarations: I have now experience in actually using any graph databases.

One could simply store the pilog declarations as lists or symbols in 
the DB, as I understand it, this is what Regenaxer did in the 
mentioned case.


The other way would be to model the data as pil DB schema, as Joh-Tob 
mentioned.


In fact the relations (to be exact: the field values, which store the 
relation) in picolisp DB are also objects!


See @lib/db.l for the implementation of +Link.

I guess one could easily use pilDB as a graph database, simply by 
creating additional prefix classes to give +Link additional type 
information (type of the edge, e.g. +Be +Loves +Has +Likes), could 
also be a prefix class which stores an additional numeric cost value 
(e.g. distance, to model "travel distance/cost" to a +Link'ed object). 
+Link would be a directed connection A -> B, while modeling a 
bidirectional connection could be done by using +Joint.
Add the prefix class +Ref to the mix, then your edges are 
automatically indexed.


I would not recommend this as a project for pilDB novices, first build 
something simpler to learn how the DB works and is to be used.


Greetings, beneroth


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: First post

2016-11-17 Thread andreas
s/Declarations/Disclaimer
s/now/no

sorry for broken English...


- Original Message -
From: andr...@itship.ch [mailto:andr...@itship.ch]
To: picolisp@software-lab.de
Sent: Thu, 17 Nov 2016 23:17:13 +0100
Subject: Re: First post

Declarations: I have now experience in actually using any graph databases.




Re: First post

2016-11-17 Thread andreas
Declarations: I have now experience in actually using any graph databases.

One could simply store the pilog declarations as lists or symbols in the DB, as 
I understand it, this is what Regenaxer did in the mentioned case.

The other way would be to model the data as pil DB schema, as Joh-Tob mentioned.

In fact the relations (to be exact: the field values, which store the relation) 
in picolisp DB are also objects!

See @lib/db.l for the implementation of +Link.

I guess one could easily use pilDB as a graph database, simply by creating 
additional prefix classes to give +Link additional type information (type of 
the edge, e.g. +Be +Loves +Has +Likes), could also be a prefix class which 
stores an additional numeric cost value (e.g. distance, to model "travel 
distance/cost" to a +Link'ed object). +Link would be a directed connection A -> 
B, while modeling a bidirectional connection could be done by using +Joint.
Add the prefix class +Ref to the mix, then your edges are automatically indexed.

I would not recommend this as a project for pilDB novices, first build 
something simpler to learn how the DB works and is to be used.

Greetings, beneroth

- Original Message -
From: Alexander Burger [mailto:a...@software-lab.de]
To: picolisp@software-lab.de
Sent: Wed, 16 Nov 2016 16:09:51 +0100
Subject: Re: First post

On Wed, Nov 16, 2016 at 03:52:02PM +0100, Joh-Tob Schäg wrote:
> Just out of curiosity:
> Is there a more elegant way to have links with properties than the way i
> mentioned?

No, looks good. The person objects are connected via +Link's or
+Joint's, and may of course have properties like a year or simply a
+Date. Also, your note about a (+List +Link) etc. is all right.

♪♫ Alex
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Date query question

2016-11-17 Thread Alexander Burger
On Thu, Nov 17, 2016 at 04:10:32PM +0100, Alexander Burger wrote:
>(?
>   @Sdate (cons Sdate T)  # Range with open end
>   @Edate (cons Edate NIL)# Reversed range with open start
>   (select (@Proj)
>  ((sDate +Proj @Sdate) (eDate +Proj @Edate))  # Search two indexes in 
> parallel
>  (range @Sdate @Proj sDate)   # Check ranges
>  (range @Edate @Proj eDate) ) )   # Check ranges

Sorry, that's probably wrong. You want both start and end to be in the
range, right? Then better:

   (?
  @Rng (cons Sdate Edate)# Range
  (select (@Proj)
 ((sDate +Proj @Rng) (eDate +Proj @Rng))  # Search two indexes in 
parallel
 (range @Rng @Proj sDate) # Check ranges
 (range @Rng @Proj eDate) ) ) # Check ranges

The corresponding 'collect' would be

   (filter
  '((This)
 (and
(>= Edate (: sDate) Sdate)
(>= Edate (: eDate) Sdate) ) )
  (collect 'sDate '+Proj Sdate (+ Edate 100)) )

Again, not tested!

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: later vs. co

2016-11-17 Thread Joe Bogner
Great! To add to the dialog, I am not surprised by co/in-row being
similar. I might have actually thought that co would be slightly
slower. This task is CPU bound which won't get any benefit from
switching coroutines, whereas later spawns new processes (workers) to
take advantage of multi-core.

Thanks for sharing.

On Thu, Nov 17, 2016 at 10:01 AM, Mike Pechkin  wrote:
> hi,
>
> https://bitbucket.org/mihailp/tankfeeder/raw/43d62edb11d56b4ffada4f728ab59b5455c97fbc/pow.l
>
> https://bitmessage.org/wiki/Proof_of_work
>
>
> I've implement more two versions for calculation Bitmessage POW on (later)
> and (co) functions. It works.
> environment:
> o) DELL PowerEdge 430 (modern)
> o) Centos 7
> o) pil64
> o) equal number (64) of workers for later and co.
>
> bench:
> o) in-row ~10 secs
> o) co ~10 secs
> o) later ~2 secs
>
> p.s. I will add all this code to bundle of tests for future releases.
>
> Mike
>
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: later vs. co

2016-11-17 Thread Alexander Burger
Hi Mike,

On Thu, Nov 17, 2016 at 05:01:24PM +0200, Mike Pechkin wrote:
> https://bitbucket.org/mihailp/tankfeeder/raw/43d62edb11d56b4ffada4f728ab59b5455c97fbc/pow.l
> 
> https://bitmessage.org/wiki/Proof_of_work

Great news! Thanks!

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Date query question

2016-11-17 Thread Alexander Burger
Hi Joe,

> For my own curiosity, should Pilog perform much better than a
> collect/filter? I would think that collect/filter should be nearly
> instant on upwards of a few thousand items (untested). When the data

Yes, I would say so too. And for larger results sets, or if multiple
indexes are involved where you don't know which one will give the best
hits, 'select' is better.


> psuedocode:
> 
> (let
>(Started (collect 'sDate '+Proj Sdate)  # find project started
> after the S date
> Ended (collect 'eDate '+Proj "1900-01-01" Edate) # find projects
> ended before the end date
> StartedBefore (collect 'sDate '+Proj "1900-01-01" Sdate) #
> projects with start date before range
> EndedAfter (collect 'eDate '+Proj Edate) # projects with end date
> after the range
> 
> 
> With this approach, the various sets would be tested and duplicates removed
> 
> maybe something like this
> 
> (uniq Started Ended (sect StartedBefore EndedAfter))
> ..
> 
> I might have the logic wrong, but I would wonder if that's faster than
> just hitting all the entries and filtering with a typical use case

I would say that multiple 'collect's, followed by merging and uniq'ing,
are more expensive.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Date query question

2016-11-17 Thread Alexander Burger
Hi Henrik,

> (class +Proj +Macropisobj)
> (rel id (+Key +Number))
> (rel nm (+Ref +String))
> (rel sDate (+Ref +String))
> (rel eDate (+Ref +String))
> 
> (dm getCurrent> (Sdate Edate)
>(filter '((P) (or
> (< Sdate (; P sDate) Edate)
> (< Sdate (; P eDate) Edate)
> (< Sdate (; P sDate) (; P eDate) Edate) ) )
>   (collect 'id This) ) )
> ...
> But how would the above problem be solved with Pilog and select if we have
> more than "a couple of hundred objects" in the database?

If you know that the *result* will be within a few hundred hits (not the
total DB size), and the difference between start and end is less than
e.g. 100 days, then you could first restrict the collection a bit

   (collect 'sDate '+Proj Sdate (+ Edate 100))

(works of course only for +Date types), and then filter that further.
This is surely the most efficient way for a small set of results.


The same you can do in Pilog with the 'db' predicate for an larger
result set, and if you want to avoid a 'select'

   (? @Rng (cons Sdate (+ Edate 100))
  (db sDate +Proj @Rng @Proj) )


But 'select' is the most general - and on big data sets perhaps the most
efficient - way. You could try

   (?
  @Sdate (cons Sdate T)  # Range with open end
  @Edate (cons Edate NIL)# Reversed range with open start
  (select (@Proj)
 ((sDate +Proj @Sdate) (eDate +Proj @Edate))  # Search two indexes in 
parallel
 (range @Sdate @Proj sDate)   # Check ranges
 (range @Edate @Proj eDate) ) )   # Check ranges

I haven't tested this ;)

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


later vs. co

2016-11-17 Thread Mike Pechkin
hi,

https://bitbucket.org/mihailp/tankfeeder/raw/43d62edb11d56b4ffada4f728ab59b5455c97fbc/pow.l

https://bitmessage.org/wiki/Proof_of_work


I've implement more two versions for calculation Bitmessage POW on (later)
and (co) functions. It works.
environment:
o) DELL PowerEdge 430 (modern)
o) Centos 7
o) pil64
o) equal number (64) of workers for later and co.

bench:
o) in-row ~10 secs
o) co ~10 secs
o) later ~2 secs

p.s. I will add all this code to bundle of tests for future releases.

Mike


Re: Date query question

2016-11-17 Thread Joe Bogner
Henrik, thanks for sharing. Interesting question!

> I can fairly trivially do a collect and then a filter on the results of the
> collect as shown above.
>
> But how would the above problem be solved with Pilog and select if we have
> more than "a couple of hundred objects" in the database?
>

For my own curiosity, should Pilog perform much better than a
collect/filter? I would think that collect/filter should be nearly
instant on upwards of a few thousand items (untested). When the data
starts to get massive, indexes could theoretically help. Working
through the logic, it seems like the various indexes would have to be
hit a few times at least

psuedocode:

(let
   (Started (collect 'sDate '+Proj Sdate)  # find project started
after the S date
Ended (collect 'eDate '+Proj "1900-01-01" Edate) # find projects
ended before the end date
StartedBefore (collect 'sDate '+Proj "1900-01-01" Sdate) #
projects with start date before range
EndedAfter (collect 'eDate '+Proj Edate) # projects with end date
after the range


With this approach, the various sets would be tested and duplicates removed

maybe something like this

(uniq Started Ended (sect StartedBefore EndedAfter))
..

I might have the logic wrong, but I would wonder if that's faster than
just hitting all the entries and filtering with a typical use case
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Date query question

2016-11-17 Thread Rafik NACCACHE
All right, but shall you need some auto-scheduling, to YU know where to
look!

Le 17 nov. 2016 12:54 PM, "Henrik Sarvell"  a écrit :

> Hi Rafik,
>
> Nice stuff, but I don't need that magic, the goal here is simply adding
> humans to projects and displaying the schedule to see who might be
> available to do new stuff at some point in time.
>
>
>
>
>
> On Thu, Nov 17, 2016 at 12:15 PM, Rafik NACCACHE  > wrote:
>
>> HEy Henrik,
>>
>> Not related by U wrote a project scheduling library and a tasks parser
>> for natural language in Clojure,
>>
>> You might want to take a look on it here:
>>
>> https://github.com/turbopape/milestones
>>
>> There is one online dome here:
>> http://turbopape.github.io/milestones/
>>
>> I'll be happy if you can review it (and why not, leave a star on it :) )
>>
>> If you want any explanationa on the scheduling algorihtm, I'll be more
>> than happy to discuss it with you !
>>
>> Cheers,
>>
>> Rafik
>>
>> 2016-11-17 12:05 GMT+01:00 Henrik Sarvell :
>>
>>> Hi list,
>>>
>>> I'm trying to build a project scheduler / planner.
>>>
>>> This is the E/R for a project:
>>>
>>> (class +Proj +Macropisobj)
>>> (rel id (+Key +Number))
>>> (rel nm (+Ref +String))
>>> (rel sDate (+Ref +String))
>>> (rel eDate (+Ref +String))
>>>
>>> (dm getCurrent> (Sdate Edate)
>>>(filter '((P) (or
>>> (< Sdate (; P sDate) Edate)
>>> (< Sdate (; P eDate) Edate)
>>> (< Sdate (; P sDate) (; P eDate) Edate) ) )
>>>   (collect 'id This) ) )
>>>
>>> I haven't decided on whether or not to use +Date yet so the above dates
>>> are on the "Y-m-d" format currently.
>>>
>>> I need to find all projects which are active during a certain time
>>> period, for instance between 2016-11-01 and 2016-12-31.
>>>
>>> Logically that means finding all projects which have either a start date
>>> or an end date in the period OR all projects with a start date before the
>>> range that also have an end date after the range.
>>>
>>> I can fairly trivially do a collect and then a filter on the results of
>>> the collect as shown above.
>>>
>>> But how would the above problem be solved with Pilog and select if we
>>> have more than "a couple of hundred objects" in the database?
>>>
>>>
>>>
>>
>>
>> --
>>
>>
>> [image: --]
>>
>> Rafik Naccache
>> [image: https://]about.me/rafik_naccache
>>
>> 
>>
>
>


Re: Date query question

2016-11-17 Thread Henrik Sarvell
Hi Rafik,

Nice stuff, but I don't need that magic, the goal here is simply adding
humans to projects and displaying the schedule to see who might be
available to do new stuff at some point in time.





On Thu, Nov 17, 2016 at 12:15 PM, Rafik NACCACHE 
wrote:

> HEy Henrik,
>
> Not related by U wrote a project scheduling library and a tasks parser for
> natural language in Clojure,
>
> You might want to take a look on it here:
>
> https://github.com/turbopape/milestones
>
> There is one online dome here:
> http://turbopape.github.io/milestones/
>
> I'll be happy if you can review it (and why not, leave a star on it :) )
>
> If you want any explanationa on the scheduling algorihtm, I'll be more
> than happy to discuss it with you !
>
> Cheers,
>
> Rafik
>
> 2016-11-17 12:05 GMT+01:00 Henrik Sarvell :
>
>> Hi list,
>>
>> I'm trying to build a project scheduler / planner.
>>
>> This is the E/R for a project:
>>
>> (class +Proj +Macropisobj)
>> (rel id (+Key +Number))
>> (rel nm (+Ref +String))
>> (rel sDate (+Ref +String))
>> (rel eDate (+Ref +String))
>>
>> (dm getCurrent> (Sdate Edate)
>>(filter '((P) (or
>> (< Sdate (; P sDate) Edate)
>> (< Sdate (; P eDate) Edate)
>> (< Sdate (; P sDate) (; P eDate) Edate) ) )
>>   (collect 'id This) ) )
>>
>> I haven't decided on whether or not to use +Date yet so the above dates
>> are on the "Y-m-d" format currently.
>>
>> I need to find all projects which are active during a certain time
>> period, for instance between 2016-11-01 and 2016-12-31.
>>
>> Logically that means finding all projects which have either a start date
>> or an end date in the period OR all projects with a start date before the
>> range that also have an end date after the range.
>>
>> I can fairly trivially do a collect and then a filter on the results of
>> the collect as shown above.
>>
>> But how would the above problem be solved with Pilog and select if we
>> have more than "a couple of hundred objects" in the database?
>>
>>
>>
>
>
> --
>
>
> [image: --]
>
> Rafik Naccache
> [image: https://]about.me/rafik_naccache
>
> 
>


Re: Date query question

2016-11-17 Thread Rafik NACCACHE
HEy Henrik,

Not related by U wrote a project scheduling library and a tasks parser for
natural language in Clojure,

You might want to take a look on it here:

https://github.com/turbopape/milestones

There is one online dome here:
http://turbopape.github.io/milestones/

I'll be happy if you can review it (and why not, leave a star on it :) )

If you want any explanationa on the scheduling algorihtm, I'll be more than
happy to discuss it with you !

Cheers,

Rafik

2016-11-17 12:05 GMT+01:00 Henrik Sarvell :

> Hi list,
>
> I'm trying to build a project scheduler / planner.
>
> This is the E/R for a project:
>
> (class +Proj +Macropisobj)
> (rel id (+Key +Number))
> (rel nm (+Ref +String))
> (rel sDate (+Ref +String))
> (rel eDate (+Ref +String))
>
> (dm getCurrent> (Sdate Edate)
>(filter '((P) (or
> (< Sdate (; P sDate) Edate)
> (< Sdate (; P eDate) Edate)
> (< Sdate (; P sDate) (; P eDate) Edate) ) )
>   (collect 'id This) ) )
>
> I haven't decided on whether or not to use +Date yet so the above dates
> are on the "Y-m-d" format currently.
>
> I need to find all projects which are active during a certain time period,
> for instance between 2016-11-01 and 2016-12-31.
>
> Logically that means finding all projects which have either a start date
> or an end date in the period OR all projects with a start date before the
> range that also have an end date after the range.
>
> I can fairly trivially do a collect and then a filter on the results of
> the collect as shown above.
>
> But how would the above problem be solved with Pilog and select if we have
> more than "a couple of hundred objects" in the database?
>
>
>


-- 


[image: --]

Rafik Naccache
[image: https://]about.me/rafik_naccache



Date query question

2016-11-17 Thread Henrik Sarvell
Hi list,

I'm trying to build a project scheduler / planner.

This is the E/R for a project:

(class +Proj +Macropisobj)
(rel id (+Key +Number))
(rel nm (+Ref +String))
(rel sDate (+Ref +String))
(rel eDate (+Ref +String))

(dm getCurrent> (Sdate Edate)
   (filter '((P) (or
(< Sdate (; P sDate) Edate)
(< Sdate (; P eDate) Edate)
(< Sdate (; P sDate) (; P eDate) Edate) ) )
  (collect 'id This) ) )

I haven't decided on whether or not to use +Date yet so the above dates are
on the "Y-m-d" format currently.

I need to find all projects which are active during a certain time period,
for instance between 2016-11-01 and 2016-12-31.

Logically that means finding all projects which have either a start date or
an end date in the period OR all projects with a start date before the
range that also have an end date after the range.

I can fairly trivially do a collect and then a filter on the results of the
collect as shown above.

But how would the above problem be solved with Pilog and select if we have
more than "a couple of hundred objects" in the database?


Unsubscribe

2016-11-17 Thread jovan

Good bye jovan  :-(
You are now unsubscribed



--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe