Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.PHONY: all build clean test

build:
jbuilder build --dev @install
dune build @install

all: build

test:
jbuilder runtest --dev
dune runtest

install:
jbuilder install --dev
dune install

uninstall:
jbuilder uninstall
dune uninstall

clean:
rm -rf _build *.install
dune clean
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 3.1)
(name facile)
2 changes: 1 addition & 1 deletion examples/coins.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let coins values max =
nb_coins) in

(* Cost: nb of coins *)
let cost = Arith.e2fd (Arith.sum_fd nb_min_coins) in
let _cost = Arith.e2fd (Arith.sum_fd nb_min_coins) in
let cost = Fd.interval 0 max in
Cstr.post (fd2e cost =~ Arith.sum_fd nb_min_coins);

Expand Down
3 changes: 3 additions & 0 deletions examples/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executables
(libraries facile)
(names coins golf golomb jobshop magic marriage prolog seven_eleven tiles))
2 changes: 1 addition & 1 deletion examples/jobshop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let js file =
List.fold_left (fun r a -> min r (T.release_date a)) max_int machs.(i) in

let ranked = Array.init nb_task (fun _ -> Stak.ref false) in
let most_critical schedules =
let most_critical _schedules =
let best = ref (-1) and slack_best = ref max_int in
for i = 0 to nb_task - 1 do
if not (Stak.get ranked.(i)) then
Expand Down
8 changes: 4 additions & 4 deletions examples/marriage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ let rankMen =
let ai2e = Array.map i2e

let go () =
let one_wife _ = Fd.create (Domain.interval 0 (Array.length women - 1))
and one_husband _ = Fd.create (Domain.interval 0 (Array.length men - 1)) in
let _one_wife _ = Fd.create (Domain.interval 0 (Array.length women - 1))
and _one_husband _ = Fd.create (Domain.interval 0 (Array.length men - 1)) in
let wife = Fd.array n 0 (n-1)
and husband = Fd.array n 0 (n-1) in
let wifee = Array.map fd2e wife
and husbande = Array.map fd2e husband in
let _wifee = Array.map fd2e wife
and _husbande = Array.map fd2e husband in

Array.iter (fun m ->
Cstr.post (fd2e (FdArray.get husband (Array.get wife m)) =~ i2e m)) men;
Expand Down
19 changes: 19 additions & 0 deletions examples/scheduling.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,79 @@ open Easy
module Task : sig
type t
(** Type of tasks. *)

val create : ?name:string -> Fd.t -> int -> t
(** [create start processing_time] return a new task with start time
[start] and constant duration [processing_time]. *)

val name : t -> string
(** [name t] return the name of task [t]. *)

val start : t -> Fd.t
(** [start t] return the start time of task [t] as a variable. *)

val end_time : t -> Arith.t
(** [end_time t] return the end time of task [t] as an expression
(i.e. [start t +~ processing_time t]). *)

val release_date : t -> int
(** [release_date t] return the earliest start time of task [t]
(i.e. [Fd.min (start t)]). *)

val processing_time : t -> int
(** [processing_time t] return the duration of task [t]. *)

val deadline : t -> int
(** [name t] return the latest completion time of task [t]
(i.e. [Fd.max (start t) + processing_time t]). *)

val before : t -> t -> Cstr.t
(** [before t1 t2] returns a constraint ensuring that [t1] is
processed before [t2]. *)

val after : t -> t -> Cstr.t
(** [after t1 t2] returns a constraint ensuring that [t1] is
processed after [t2]. *)

val update_release_date : t -> int -> unit
(** [update_release_date t start] refine task [t] so that it
cannot begin before [start]. *)

val update_deadline : t -> int -> unit
(** [update_deadline t endtime] refine task [t] so that it
cannot end after [endtime]. *)

val fprint : out_channel -> t -> unit
(** [fprint chan t] print task [t] on out channel [chan]. *)
end

type t
(** Type of unary ressource. They are associated with the set
of tasks which require it. *)

val fprint : out_channel -> t -> unit
(** [fprint chan r] print ressource [r] (i.e. the set of tasks
which require it) on out channel [chan]. *)

val create : Task.t list -> t
(** [create ts] return a new ressource which must process (if constrained)
all tasks in list [ts]. *)

val tasks : t -> Task.t list
(** [tasks r] return the list of tasks that require [r]. *)

val iter : (Task.t -> unit) -> t -> unit
(** [iter f r] iterate on all tasks requiring ressource [r]. *)

val number_of_tasks : t -> int
(** [number_of_tasks r] return the number of tasks requiring
ressource [r]. *)

val edge_finding : t -> Cstr.t
(** [edge_finding r] return a unary capacity constraint on
ressource [r]. Propagations are performed with the edge-finding
bounding algorithm. *)

val disjunctive : t -> Cstr.t
(** [disjunctive r] return a unary capacity constraint on
ressource [r]. Propagations are performed by pairwise
Expand Down
9 changes: 5 additions & 4 deletions facile.opam
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ bug-reports: "https://github.com/Emmanuel-PLF/facile/issues"
dev-repo: "https://github.com/Emmanuel-PLF/facile.git"

build: [
[ "jbuilder" "subst"] {pinned}
["jbuilder" "build" "-p" name "-j" jobs]
[ "dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
build-test: [
["jbuilder" "runtest" "-p" name]
["dune" "runtest" "-p" name]
]
depends: [
"jbuilder" {build & >= "1.0+beta10"}
"dune" {build}
"stdlib-shims"
]
available: [ ocaml-version >= "4.03.0" ]
5 changes: 5 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(public_name facile)
(libraries stdlib-shims)
(ocamlopt_flags (-unsafe -noassert -inline 10))
)
2 changes: 1 addition & 1 deletion lib/fcl_cstr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let create ?(name = "anonymous") ?(nb_wakings = 1) ?fprint ?(priority = normal)
and nb_solved = Fcl_stak.ref 0 in
let update i =
if update i then
if Pervasives.not solved.(i) then begin
if Stdlib.not solved.(i) then begin
Fcl_stak.set nb_solved (Fcl_stak.get nb_solved + 1);
array_set_true solved i
end in
Expand Down
2 changes: 1 addition & 1 deletion lib/fcl_fdArray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ let get array index =
let (mi, ma) =
Array.fold_left
(fun (mi, ma) e ->
(Pervasives.min mi (Fd.min e), Pervasives.max ma (Fd.max e)))
(Stdlib.min mi (Fd.min e), Stdlib.max ma (Fd.max e)))
(max_int, min_int) array in
if mi = ma then Fd.int mi else
let value = Fd.create (Fcl_domain.interval mi ma) in
Expand Down
6 changes: 3 additions & 3 deletions lib/fcl_misc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ module Operators = struct
x - y
*)

let (+) = Pervasives.(+)
let (-) = Pervasives.(-)
let ( * ) = Pervasives.( * )
let (+) = Stdlib.(+)
let (-) = Stdlib.(-)
let ( * ) = Stdlib.( * )

let (=+) x y = x := !x + y
let (=+.) x y = x := !x +. y
Expand Down
2 changes: 1 addition & 1 deletion lib/fcl_nonlinear.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ let min_max_of_div_for_div a b z =
let min_max_of_remainder x y =
let r_abs_max =
let min_y, max_y = Fd.min_max y in
max (Pervasives.abs min_y) (Pervasives.abs max_y) - 1 in
max (Stdlib.abs min_y) (Stdlib.abs max_y) - 1 in
if Fd.min x >= 0 then (0, r_abs_max)
else if Fd.max x <= 0 then ((0 - r_abs_max), 0)
else ((0 - r_abs_max), r_abs_max)
Expand Down
4 changes: 2 additions & 2 deletions lib/fcl_sorting.ml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ let sortp a =
else
let inf, sup =
Array.fold_left
(fun (inf, sup) x -> Pervasives.min (Fd.min x) inf, Pervasives.max (Fd.max x) sup) (max_int, min_int) a in
(fun (inf, sup) x -> Stdlib.min (Fd.min x) inf, Stdlib.max (Fd.max x) sup) (max_int, min_int) a in
let d = Fd.array n inf sup
and p = Fd.array n 0 (n - 1) in
Fcl_cstr.post (cstr a ~p:(Some p) d);
Expand All @@ -368,7 +368,7 @@ let sort a =
else
let inf, sup =
Array.fold_left
(fun (inf, sup) x -> Pervasives.min (Fd.min x) inf, Pervasives.max (Fd.max x) sup) (max_int, min_int) a in
(fun (inf, sup) x -> Stdlib.min (Fd.min x) inf, Stdlib.max (Fd.max x) sup) (max_int, min_int) a in
let d = Fd.array n inf sup in
Fcl_cstr.post (cstr a d);
d;;
7 changes: 7 additions & 0 deletions lib_test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(libraries facile)
(name queens))

(rule
(alias runtest)
(action (run ./queens.exe 8)))