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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
(* ASCEND modelling environment
Copyright (C) 1997 Carnegie Mellon University
Copyright (C) 2006 Carnegie Mellon University
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
REQUIRE "atoms.a4l";
(*
This model is the second example in "Solved simple models with ASCEND."
@TODO add a citation and/or brief problem description
by Arthur Westerberg, 1997.
*)
MODEL travel_distance;
kmax IS_A integer_constant;
v[1..2*kmax+1] IS_A speed;
delta_time IS_A time;
d IS_A distance;
d = SUM[
v[2*k-1] + 4*v[2*k] + v[2*k+1]
SUCH_THAT k IN [1..kmax]
] * delta_time/6;
END travel_distance;
MODEL distance_calc REFINES travel_distance;
kmax :== 5;
METHODS
METHOD specify;
FIX v[1..2*kmax+1];
FIX delta_time;
END specify;
METHOD values;
v[1] := 100 {ft/min};
v[2] := 120 {ft/min};
v[3] := 130 {ft/min};
v[4] := 135 {ft/min};
v[5] := 140 {ft/min};
v[6] := 160 {ft/min};
v[7] := 180 {ft/min};
v[8] := 210 {ft/min};
v[9] := 240 {ft/min};
v[10] := 220 {ft/min};
v[11] := 200 {ft/min};
delta_time := 10 {s};
END values;
METHOD on_load;
RUN reset;
RUN values;
END on_load;
METHOD self_test;
ASSERT abs(d - 42.84 {m}) < 1 {cm};
END self_test;
END distance_calc;
|