/[ascend]/trunk/models/z-exttest.a4c
ViewVC logotype

Annotation of /trunk/models/z-exttest.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 908 - (hide annotations) (download) (as text)
Thu Oct 26 10:18:53 2006 UTC (17 years, 8 months ago) by johnpye
File MIME type: text/x-ascend
File size: 8439 byte(s)
first attempt at merging with Ben's changes on the trunk
1 johnpye 908 REQUIRE "system.a4l";
2     REQUIRE "basemodel.a4l";
3     (* still not working. working on it. baa *)
4     (*IMPORT "bboxtest";*)
5    
6     MODEL test1multi( coef IS_A real_constant; );
7    
8     npts IS_A integer_constant;
9     npts :== 4;
10     x[1..npts][1..3] IS_A generic_real;
11     y[1..npts][1..3] IS_A generic_real;
12    
13     (* do a gratuitous array of relations just to verify that rel arrays aren't busted too. *)
14    
15     FOR i IN [1..npts-1] CREATE
16     FOR j IN [1..3] CREATE
17     tie_x[i][j]: x[i][j] = x[i+1][j];
18     END FOR;
19     END FOR;
20    
21     (*
22     bbox: y = coef*x;
23     *)
24     (* the simple repeated npts times *)
25     FOR i IN [1..npts] CREATE
26     bbox[i]: bboxtest( x[i][1..3] : INPUT ;
27     y[i][1..3] : OUTPUT ;
28     coef : DATA);
29     END FOR;
30    
31     (* the odd repeated npts triangle of times.
32     Verifies that each instance gets its own argument
33     evaluation in FOR processing.
34     *)
35     FOR i IN [1..npts] CREATE
36     FOR j IN [1..i] CREATE
37     xT[i][j] IS_A generic_real;
38     yT[i][j] IS_A generic_real;
39     END FOR;
40     END FOR;
41     FOR i IN [1..npts] CREATE
42     bboxT[i]: bboxtest( xT[i][1..i] : INPUT ;
43     yT[i][1..i] : OUTPUT ;
44     coef : DATA);
45     END FOR;
46    
47     METHODS
48    
49     METHOD default_self;
50     y[1..npts][1..3] := -1.0 ;
51     x[1..npts][1..3] := 1.0 ;
52     FOR i IN [1..npts] DO
53     FOR j IN [1..i] DO
54     xT[i][j] := 1.0;
55     yT[i][j] := -1.0;
56     END FOR;
57     END FOR;
58     END default_self;
59    
60     METHOD reset;
61     EXTERNAL asc_free_all_variables(SELF);
62     RUN specify;
63     END reset;
64    
65     METHOD specify;
66     FOR i IN [1..npts-1] DO
67     FOR j IN [1..3] DO
68     tie_x[i][j].included := FALSE;
69     END FOR;
70     END FOR;
71     FIX x[1..npts][1..3];
72     FREE y[1..npts][1..3];
73     FOR i IN [1..npts] DO
74     FOR j IN [1..i] DO
75     FIX xT[i][j];
76     FREE yT[i][j];
77     END FOR;
78     END FOR;
79     END specify;
80    
81     METHOD default_all;
82     RUN default_self;
83     END default_all;
84    
85     END test1multi;
86    
87     MODEL test2multi
88     REFINES testcmumodel;
89    
90     one IS_A real_constant;
91     one :== 1.0;
92    
93     t1 IS_A test1multi(one);
94    
95     METHODS
96    
97     METHOD specify;
98     RUN t1.reset;
99     END specify;
100    
101     METHOD default_self;
102     RUN t1.default_self;
103     END default_self;
104    
105     METHOD default_all;
106     RUN default_self;
107     END default_all;
108    
109     END test2multi;
110    
111     MODEL test1(
112     coef IS_A real_constant;
113     );
114     x[1..3] IS_A generic_real;
115     y[1..3] IS_A generic_real;
116    
117    
118     (*
119     bbox[i]: y[i] = coef*x[i];
120     *)
121     bbox: bboxtest( x[1..3] : INPUT ;
122     y[1..3] : OUTPUT ;
123     coef : DATA);
124    
125     METHODS
126    
127     METHOD default_self;
128     y[1..3] := -1.0 ;
129     x[1..3] := 1.0 ;
130     END default_self;
131    
132     METHOD reset;
133     EXTERNAL asc_free_all_variables(SELF);
134     RUN specify;
135     END reset;
136    
137     METHOD specify;
138     FIX x[1..3];
139     FREE y[1..3];
140     END specify;
141    
142     METHOD default_all;
143     RUN default_self;
144     END default_all;
145    
146     END test1;
147    
148    
149     MODEL test2
150     REFINES testcmumodel;
151    
152     one IS_A real_constant;
153     one :== 1.0;
154     two IS_A real_constant;
155     two :== 2.0;
156    
157     t1 IS_A test1(one);
158    
159     t2 IS_A test1(two);
160    
161     t_merge_xy IS_A test1(two);
162     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
163    
164     t_merge_x IS_A test1(two);
165     t_merge_x.x[1..2] ARE_THE_SAME;
166    
167     t_merge_y IS_A test1(two);
168     t_merge_y.y[1..2] ARE_THE_SAME;
169    
170     t_shift_xy IS_A test1(two);
171     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
172    
173     METHODS
174    
175     METHOD specify;
176     RUN t1.reset;
177     RUN t2.reset;
178     RUN t_merge_x.reset;
179     RUN t_merge_xy.reset;
180     RUN t_merge_y.reset;
181     FREE t_merge_y.x[2];
182     RUN t_shift_xy.reset;
183     END specify;
184    
185     METHOD default_self;
186     RUN t1.default_self;
187     RUN t2.default_self;
188     RUN t_merge_x.default_self;
189     RUN t_merge_xy.default_self;
190     RUN t_merge_y.default_self;
191     RUN t_shift_xy.default_self;
192     END default_self;
193    
194     METHOD default_all;
195     RUN default_self;
196     END default_all;
197    
198     END test2;
199    
200     MODEL test1Array
201     REFINES testcmumodel;
202    
203     one IS_A real_constant;
204     one :== 1.0;
205    
206     t[1..3] IS_A test1(one);
207    
208     METHODS
209    
210     METHOD specify;
211     RUN t[1..3].reset;
212     END specify;
213    
214     METHOD default_self;
215     RUN t[1..3].default_self;
216     END default_self;
217    
218     METHOD default_all;
219     RUN default_self;
220     END default_all;
221    
222     END test1Array;
223    
224    
225     MODEL test2Array REFINES testcmumodel;
226    
227     a[1..3] IS_A test2;
228    
229     METHODS
230    
231     METHOD reset;
232     RUN a[1..3].reset;
233     END reset;
234    
235     METHOD specify;
236     RUN a[1..3].specify;
237     END specify;
238    
239     METHOD default_all;
240     RUN default_self;
241     END default_all;
242    
243     METHOD default_self;
244     RUN a[1..3].default_self;
245     END default_self;
246    
247     END test2Array;
248    
249    
250     MODEL test1_normal(coef IS_A real_constant;);
251    
252     x[1..3] IS_A generic_real;
253     y[1..3] IS_A generic_real;
254    
255     FOR i IN [1..3] CREATE
256     bbox[i]: y[i] = coef*x[i];
257     END FOR;
258    
259     METHODS
260    
261     METHOD default_self;
262     y[1..3] := -1.0 ;
263     x[1] := 1;
264     x[2] := 2;
265     x[3] := 3;
266     END default_self;
267    
268     METHOD default_all;
269     RUN default_self;
270     END default_all;
271    
272     METHOD specify;
273     FIX x[1..3];
274     FREE y[1..3];
275     END specify;
276    
277    
278     END test1_normal;
279    
280     MODEL test2_normal
281     REFINES testcmumodel;
282     one IS_A real_constant;
283     one :== 1.0;
284     two IS_A real_constant;
285     two :== 2.0;
286    
287     t1 IS_A test1_normal(one);
288    
289     t2 IS_A test1_normal(two);
290    
291     t_merge_xy IS_A test1_normal(two);
292     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
293    
294     t_merge_x IS_A test1_normal(two);
295     t_merge_x.x[1..2] ARE_THE_SAME;
296    
297     t_merge_y IS_A test1_normal(two);
298     t_merge_y.y[1..2] ARE_THE_SAME;
299    
300     t_shift_xy IS_A test1_normal(two);
301     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
302    
303     METHODS
304    
305     METHOD specify;
306     RUN t1.reset;
307     RUN t2.reset;
308     RUN t_merge_x.reset;
309     RUN t_merge_xy.reset;
310     RUN t_merge_y.reset;
311     FREE t_merge_y.x[2];
312     RUN t_shift_xy.reset;
313     END specify;
314    
315     METHOD default_self;
316     RUN t1.default_self;
317     RUN t2.default_self;
318     RUN t_merge_x.default_self;
319     RUN t_merge_xy.default_self;
320     RUN t_merge_y.default_self;
321     RUN t_shift_xy.default_self;
322     END default_self;
323    
324     METHOD default_all;
325     RUN default_self;
326     END default_all;
327    
328     END test2_normal;
329    
330    
331     MODEL testrefinement_base_normal
332     REFINES testcmumodel;
333     one IS_A real_constant;
334     one :== 1.0;
335     two IS_A real_constant;
336     two :== 2.0;
337    
338     t1 IS_A test1_normal(one);
339     t2 IS_A test1_normal(two);
340     t_merge_xy IS_A test1_normal(two);
341     t_merge_x IS_A test1_normal(two);
342     t_merge_y IS_A test1_normal(two);
343     t_shift_xy IS_A test1_normal(two);
344    
345     (* we'll do this bit interactively by refinement to detect bugs in the multipass
346     scheme of instantiation.
347     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
348     t_merge_x.x[1..2] ARE_THE_SAME;
349     t_merge_y.y[1..2] ARE_THE_SAME;
350     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
351     *)
352    
353     METHODS
354    
355     METHOD specify;
356     RUN t1.reset;
357     RUN t2.reset;
358     RUN t_merge_x.reset;
359     RUN t_merge_xy.reset;
360     RUN t_merge_y.reset;
361     RUN t_shift_xy.reset;
362     END specify;
363    
364     METHOD default_self;
365     RUN t1.default_self;
366     RUN t2.default_self;
367     RUN t_merge_x.default_self;
368     RUN t_merge_xy.default_self;
369     RUN t_merge_y.default_self;
370     RUN t_shift_xy.default_self;
371     END default_self;
372    
373     METHOD default_all;
374     RUN default_self;
375     END default_all;
376    
377     END testrefinement_base_normal;
378    
379     MODEL testrefinement_normal
380     REFINES testrefinement_base_normal;
381     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
382     t_merge_x.x[1..2] ARE_THE_SAME;
383     t_merge_y.y[1..2] ARE_THE_SAME;
384     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
385    
386     METHODS
387    
388     METHOD specify;
389     RUN t1.reset;
390     RUN t2.reset;
391     RUN t_merge_x.reset;
392     RUN t_merge_xy.reset;
393     RUN t_merge_y.reset;
394     RUN t_shift_xy.reset;
395     FREE t_merge_y.x[2];
396     END specify;
397    
398     END testrefinement_normal;
399    
400     MODEL testrefinement_base
401     REFINES testcmumodel;
402     one IS_A real_constant;
403     one :== 1.0;
404     two IS_A real_constant;
405     two :== 2.0;
406    
407     t1 IS_A test1(one);
408     t2 IS_A test1(two);
409     t_merge_xy IS_A test1(two);
410     t_merge_x IS_A test1(two);
411     t_merge_y IS_A test1(two);
412     t_shift_xy IS_A test1(two);
413    
414     (* we'll do this bit interactively by refinement to detect bugs in the multipass
415     scheme of instantiation.
416     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
417     t_merge_x.x[1..2] ARE_THE_SAME;
418     t_merge_y.y[1..2] ARE_THE_SAME;
419     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
420     *)
421    
422     METHODS
423    
424     METHOD specify;
425     RUN t1.reset;
426     RUN t2.reset;
427     RUN t_merge_x.reset;
428     RUN t_merge_xy.reset;
429     RUN t_merge_y.reset;
430     RUN t_shift_xy.reset;
431     END specify;
432    
433     METHOD default_self;
434     RUN t1.default_self;
435     RUN t2.default_self;
436     RUN t_merge_x.default_self;
437     RUN t_merge_xy.default_self;
438     RUN t_merge_y.default_self;
439     RUN t_shift_xy.default_self;
440     END default_self;
441    
442     METHOD default_all;
443     RUN default_self;
444     END default_all;
445    
446     END testrefinement_base;
447    
448     MODEL testrefinement
449     REFINES testrefinement_base;
450     t_merge_xy.x[1], t_merge_xy.y[1] ARE_THE_SAME;
451     t_merge_x.x[1..2] ARE_THE_SAME;
452     t_merge_y.y[1..2] ARE_THE_SAME;
453     t_shift_xy.x[2], t_shift_xy.y[1] ARE_THE_SAME;
454    
455     METHODS
456    
457     METHOD specify;
458     RUN t1.reset;
459     RUN t2.reset;
460     RUN t_merge_x.reset;
461     RUN t_merge_xy.reset;
462     RUN t_merge_y.reset;
463     RUN t_shift_xy.reset;
464     FREE t_merge_y.x[2];
465     END specify;
466    
467     END testrefinement;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22