-
Notifications
You must be signed in to change notification settings - Fork 9
/
task.ml
62 lines (51 loc) · 2.03 KB
/
task.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(* ========================================================================== *)
(* FPTaylor: A Tool for Rigorous Estimation of Round-off Errors *)
(* *)
(* Author: Alexey Solovyev, University of Utah *)
(* *)
(* This file is distributed under the terms of the MIT license *)
(* ========================================================================== *)
(* -------------------------------------------------------------------------- *)
(* FPTaylor input task *)
(* -------------------------------------------------------------------------- *)
open Expr
open Interval
type var_info = {
var_name : string;
var_type : Rounding.value_type;
lo_bound : Const.t;
hi_bound : Const.t;
uncertainty : Const.t;
}
type task = {
name : string;
expression : expr;
variables : var_info list;
constraints : (string * formula) list;
}
let all_variables t =
List.map (fun v -> v.var_name) t.variables
let all_active_variables t =
let vars = Expr.vars_in_expr t.expression in
let names = all_variables t in
List.filter (fun name -> List.mem name vars) names
let find_variable t name =
List.find (fun v -> v.var_name = name) t.variables
let variable_type t name =
(find_variable t name).var_type
let variable_interval t name =
let var = find_variable t name in {
low = (Const.to_interval var.lo_bound).low;
high = (Const.to_interval var.hi_bound).high;
}
let variable_num_interval t name =
let var = find_variable t name in
let low = Const.low_bound_to_num var.lo_bound in
let high = Const.high_bound_to_num var.hi_bound in
(low, high)
let constraints_of_task t = {
var_interval = variable_interval t;
var_rat_bounds = variable_num_interval t;
var_uncertainty = (fun name -> (find_variable t name).uncertainty);
Expr.constraints = List.map snd t.constraints;
}