mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
rename a Vec function
`grow_to_by_double` becomes `grow_to_at_least` so that it doesn't specify its own implementation's strategy
This commit is contained in:
parent
c64a94c2aa
commit
6be7e7c71a
5 changed files with 18 additions and 19 deletions
|
|
@ -783,9 +783,9 @@ module Make
|
||||||
if not (Stack.is_empty env.clauses_to_add) then begin
|
if not (Stack.is_empty env.clauses_to_add) then begin
|
||||||
let nbv = St.nb_elt () in
|
let nbv = St.nb_elt () in
|
||||||
let nbc = env.nb_init_clauses + Stack.length env.clauses_to_add in
|
let nbc = env.nb_init_clauses + Stack.length env.clauses_to_add in
|
||||||
Iheap.grow_to_by_double env.order nbv;
|
Iheap.grow_to_at_least env.order nbv;
|
||||||
Vec.grow_to_by_double env.clauses_hyps nbc;
|
Vec.grow_to_at_least env.clauses_hyps nbc;
|
||||||
Vec.grow_to_by_double env.clauses_learnt nbc;
|
Vec.grow_to_at_least env.clauses_learnt nbc;
|
||||||
env.nb_init_clauses <- nbc;
|
env.nb_init_clauses <- nbc;
|
||||||
while not (Stack.is_empty env.clauses_to_add) do
|
while not (Stack.is_empty env.clauses_to_add) do
|
||||||
let c = Stack.pop env.clauses_to_add in
|
let c = Stack.pop env.clauses_to_add in
|
||||||
|
|
@ -898,7 +898,7 @@ module Make
|
||||||
|
|
||||||
let slice_propagate f lvl =
|
let slice_propagate f lvl =
|
||||||
let a = atom f in
|
let a = atom f in
|
||||||
Iheap.grow_to_by_double env.order (St.nb_elt ());
|
Iheap.grow_to_at_least env.order (St.nb_elt ());
|
||||||
enqueue_bool a lvl (Semantic lvl)
|
enqueue_bool a lvl (Semantic lvl)
|
||||||
|
|
||||||
let current_slice (): (_,_,_) Plugin_intf.slice = {
|
let current_slice (): (_,_,_) Plugin_intf.slice = {
|
||||||
|
|
@ -935,7 +935,7 @@ module Make
|
||||||
| Plugin_intf.Unsat (l, p) ->
|
| Plugin_intf.Unsat (l, p) ->
|
||||||
(* conflict *)
|
(* conflict *)
|
||||||
let l = List.rev_map new_atom l in
|
let l = List.rev_map new_atom l in
|
||||||
Iheap.grow_to_by_double env.order (St.nb_elt ());
|
Iheap.grow_to_at_least env.order (St.nb_elt ());
|
||||||
List.iter (fun a -> insert_var_order (elt_of_var a.var)) l;
|
List.iter (fun a -> insert_var_order (elt_of_var a.var)) l;
|
||||||
let c = St.make_clause (St.fresh_tname ()) l (Lemma p) in
|
let c = St.make_clause (St.fresh_tname ()) l (Lemma p) in
|
||||||
Some c
|
Some c
|
||||||
|
|
@ -1175,7 +1175,7 @@ module Make
|
||||||
end else begin
|
end else begin
|
||||||
(* Grow the heap, because when the lit is backtracked,
|
(* Grow the heap, because when the lit is backtracked,
|
||||||
it will be added to the heap. *)
|
it will be added to the heap. *)
|
||||||
Iheap.grow_to_by_double env.order (St.nb_elt ());
|
Iheap.grow_to_at_least env.order (St.nb_elt ());
|
||||||
(* make a decision, propagate *)
|
(* make a decision, propagate *)
|
||||||
let level = decision_level() in
|
let level = decision_level() in
|
||||||
enqueue_bool a ~level (Bcp c);
|
enqueue_bool a ~level (Bcp c);
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,9 @@ let insert cmp s n =
|
||||||
percolate_up cmp s (V.get s.indices n)
|
percolate_up cmp s (V.get s.indices n)
|
||||||
end
|
end
|
||||||
|
|
||||||
let grow_to_by_double s sz =
|
let grow_to_at_least s sz =
|
||||||
V.resize s.indices sz;
|
V.resize s.indices sz;
|
||||||
Vec.grow_to_by_double s.heap sz
|
Vec.grow_to_at_least s.heap sz
|
||||||
|
|
||||||
(*
|
(*
|
||||||
let update cmp s n =
|
let update cmp s n =
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ val clear : t -> unit
|
||||||
val insert : (int -> int -> bool) -> t -> int -> unit
|
val insert : (int -> int -> bool) -> t -> int -> unit
|
||||||
(** Insert a new integer into the heap, according to the given comparison *)
|
(** Insert a new integer into the heap, according to the given comparison *)
|
||||||
|
|
||||||
val grow_to_by_double: t -> int -> unit
|
val grow_to_at_least: t -> int -> unit
|
||||||
(** Hint: augment the internal capacity of the heap until it reaches at
|
(** Hint: augment the internal capacity of the heap until it reaches at
|
||||||
least the given integer *)
|
least the given integer *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,22 +57,19 @@ let size t = t.sz
|
||||||
|
|
||||||
let is_empty t = t.sz = 0
|
let is_empty t = t.sz = 0
|
||||||
|
|
||||||
let grow_to t new_capa =
|
let grow_to_exact t new_capa =
|
||||||
assert (new_capa >= Array.length t.data);
|
assert (new_capa >= Array.length t.data);
|
||||||
let new_data = Array.make new_capa t.dummy in
|
let new_data = Array.make new_capa t.dummy in
|
||||||
assert (t.sz <= new_capa);
|
assert (t.sz <= new_capa);
|
||||||
let old = t.data in
|
Array.blit t.data 0 new_data 0 t.sz;
|
||||||
for i = 0 to t.sz - 1 do
|
|
||||||
Array.unsafe_set new_data i (Array.unsafe_get old i)
|
|
||||||
done;
|
|
||||||
t.data <- new_data
|
t.data <- new_data
|
||||||
|
|
||||||
let grow_to_double_size t =
|
let grow_to_double_size t =
|
||||||
if Array.length t.data = Sys.max_array_length then _size_too_big();
|
if Array.length t.data = Sys.max_array_length then _size_too_big();
|
||||||
let size = min Sys.max_array_length (2* Array.length t.data + 1) in
|
let size = min Sys.max_array_length (2* Array.length t.data + 1) in
|
||||||
grow_to t size
|
grow_to_exact t size
|
||||||
|
|
||||||
let grow_to_by_double t new_capa =
|
let grow_to_at_least t new_capa =
|
||||||
assert (new_capa >= 0);
|
assert (new_capa >= 0);
|
||||||
if new_capa > Sys.max_array_length then _size_too_big ();
|
if new_capa > Sys.max_array_length then _size_too_big ();
|
||||||
let data = t.data in
|
let data = t.data in
|
||||||
|
|
@ -80,7 +77,7 @@ let grow_to_by_double t new_capa =
|
||||||
while !capa < new_capa do
|
while !capa < new_capa do
|
||||||
capa := min (2 * !capa + 1) Sys.max_array_length;
|
capa := min (2 * !capa + 1) Sys.max_array_length;
|
||||||
done;
|
done;
|
||||||
grow_to t !capa
|
grow_to_exact t !capa
|
||||||
|
|
||||||
let is_full t = Array.length t.data = t.sz
|
let is_full t = Array.length t.data = t.sz
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,13 @@ val size : 'a t -> int
|
||||||
|
|
||||||
val is_empty : 'a t -> bool
|
val is_empty : 'a t -> bool
|
||||||
|
|
||||||
val grow_to : 'a t -> int -> unit
|
val grow_to_exact : 'a t -> int -> unit
|
||||||
|
|
||||||
val grow_to_double_size : 'a t -> unit
|
val grow_to_double_size : 'a t -> unit
|
||||||
|
|
||||||
val grow_to_by_double : 'a t -> int -> unit
|
val grow_to_at_least : 'a t -> int -> unit
|
||||||
|
(** [grow_to_at_least vec n] ensures that [capacity vec >= n] in
|
||||||
|
the most efficient way *)
|
||||||
|
|
||||||
val is_full : 'a t -> bool
|
val is_full : 'a t -> bool
|
||||||
(** Is the capacity of the vector equal to the number of its elements? *)
|
(** Is the capacity of the vector equal to the number of its elements? *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue