caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Diego Olivier Fernandez Pons <dofp.ocaml@gmail.com>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Dynamic graph algorithms
Date: Thu, 10 Nov 2011 12:13:02 +0100	[thread overview]
Message-ID: <CAHqiZ-KQxkc6cWLCfrMok=rz=U_Psg=DA=Mvrtm+w3rijgd_3A@mail.gmail.com> (raw)
In-Reply-To: <006501cc9e61$ac282470$04786d50$@ffconsultancy.com>

[-- Attachment #1: Type: text/plain, Size: 2164 bytes --]

    Jon,

In ML there has been work on self adjusting computations (check the work of
Amut Acar and unfold recursively).
Dynamic graphs are in a sense an optimization of self-adjusting
computations in the same way logical persistence is an optimization of
physical persistence

Lets say I have an backtracking algorithm that uses a set data structure. I
have two implementation possibilities
- physical persistence : restore the data structure to its (physical)
previous states
- logical persistence : store changes and restore them when I am
backtracking (the sets will be represented by a different physical tree)

(* Physical persistence *)
let rec subsetsum = fun target candidates ->
  match target with
    | 0 -> Some []
    | n when n > 0 ->
      if IntSet.is_empty candidates then None
      else
(
  let value = IntSet.choose candidates in
  let remaining_candidates = IntSet.remove value candidates in
  match subsetsum (target - value) (IntSet.filter (fun x -> x <= target -
value) remaining_candidates)
  with
    | None -> subsetsum target remaining_candidates
    | Some list -> Some (value :: list)
 )
    | _ -> failwith "incorrect argument : negative target"

(* Logical persistence *)

let add_list = List.fold_left (fun s v -> IntSet.add v s)

let rec subsetsum = fun target candidates ->
  match target with
    | 0 -> Some []
    | n when n < 0 || IntSet.is_empty candidates -> None
    | _ ->
      let value = IntSet.choose candidates in
      let removed = IntSet.elements (IntSet.filter (fun x -> x > target -
value) candidates) in
      let candidates = IntSet.remove value (IntSet.filter (fun x -> x <=
target - value) candidates) in
      match subsetsum (target - value) candidates
      with
| None -> subsetsum target (add_list (IntSet.add value candidates) removed)
 | Some list -> Some (value :: list)

In self-adjusting systems, whenever a data changes, the sequence of
computations is replayed from the last common node (like the inner match in
the loop of a backtracking algorithm). In dynamic algorithms for problem
XXX there is an algorithm that restores an equivalent state (typically an
invariant).

        Diego Olivier

[-- Attachment #2: Type: text/html, Size: 3231 bytes --]

  reply	other threads:[~2011-11-10 11:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 21:59 Jon Harrop
2011-11-10 11:13 ` Diego Olivier Fernandez Pons [this message]
2011-11-18 11:13   ` Diego Olivier Fernandez Pons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHqiZ-KQxkc6cWLCfrMok=rz=U_Psg=DA=Mvrtm+w3rijgd_3A@mail.gmail.com' \
    --to=dofp.ocaml@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jon@ffconsultancy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).