/[ascend]/trunk/solvers/conopt/conopttest.a4c
ViewVC logotype

Contents of /trunk/solvers/conopt/conopttest.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1504 - (show annotations) (download) (as text)
Sat Jun 23 14:12:34 2007 UTC (16 years, 5 months ago) by jpye
File MIME type: text/x-ascend
File size: 1218 byte(s)
Moving solvers to their own directory
1 REQUIRE "atoms.a4l";
2
3 IMPORT "johnpye/conopt/conopt";
4
5 (*
6 This example model comes from the CONOPT documentation, which is
7 distributed with CONOPT.
8 *)
9 MODEL conopttest;
10 Profit, Inp, Out IS_A solver_var;
11 P, L IS_A solver_var;
12
13 K IS_A real_constant;
14 Al, Ak, Ainp, Rho IS_A solver_var;
15 Pinp, P0, D IS_A real_constant;
16 W, L0, K0 IS_A real_constant;
17
18 cesfn: Out = ( Al*L^(-Rho) + Ak*K^(-Rho) + Ainp*Inp^(-Rho) )^(-1/Rho);
19
20 demandfn: Out = ( P0 - P ) / D;
21
22 W :== 1.0;
23 L0 :== 0.1;
24 Pinp :== 1.0;
25
26 K0 :== 4.0;
27 P0 :== 2.0;
28 D :== 0.5;
29 K :== K0;
30
31 profitfn: Profit = P*Out - (L-L0)*W - Inp*Pinp;
32 maxprofit: MAXIMIZE Profit;
33
34 METHODS
35
36 METHOD default_self;
37 L := 0.5;
38 Inp := 0.5;
39 END default_self;
40
41 METHOD specify;
42 FIX Al, Ak, Ainp, Rho;
43 END specify;
44
45 METHOD values;
46 Al := 0.16;
47 Ak := 2.00;
48 Ainp := 0.16;
49 Rho := 1.0;
50
51 L.lower_bound := L0;
52 P.lower_bound := 0;
53 Out.lower_bound := 0;
54 Inp.lower_bound := -0.001;
55 END values;
56
57 METHOD on_load;
58 RUN default_self;
59 RUN specify;
60 RUN values;
61 END on_load;
62
63 METHOD self_test;
64 ASSERT abs(L - 0.295686) < 0.000001;
65 ASSERT abs(Inp - 0.295686) < 0.000001;
66 ASSERT abs(Out - 0.632019) < 0.000001;
67 ASSERT abs(P - 1.683990) < 0.000001;
68 END self_test;
69
70 END conopttest;

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