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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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