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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 789 - (hide annotations) (download) (as text)
Thu Jul 27 04:35:17 2006 UTC (17 years, 2 months ago) by johnpye
Original Path: trunk/models/johnpye/testconopt.a4c
File MIME type: text/x-ascend
File size: 1068 byte(s)
Working version of testconopt.a4c now. This model yeilds the solution given in the CONOPT tutorial.
1 johnpye 786 REQUIRE "atoms.a4l";
2    
3     MODEL testconopt;
4     Profit, Inp, Out IS_A solver_var;
5 johnpye 788 P, L IS_A solver_var;
6 johnpye 786
7 johnpye 788 K IS_A real_constant;
8 johnpye 786 Al, Ak, Ainp, Rho IS_A real_constant;
9     Pinp, P0, D IS_A real_constant;
10     W, L0, K0 IS_A real_constant;
11    
12 johnpye 788 cesfn: Out = ( Al*L^(-Rho) + Ak*K^(-Rho) + Ainp*Inp^(-Rho) )^(-1/Rho);
13 johnpye 786
14 johnpye 788 demandfn: Out = ( P0 - P ) / D;
15 johnpye 786
16     W :== 1.0;
17     L0 :== 0.1;
18     Pinp :== 1.0;
19     Al :== 0.16;
20     Ak :== 2.00;
21     Ainp :== 0.16;
22     Rho :== 1.0;
23     K0 :== 4.0;
24     P0 :== 2.0;
25     D :== 0.5;
26 johnpye 788 K :== K0;
27 johnpye 786
28 johnpye 788 profitfn: Profit = P*Out - (L-L0)*W - Inp*Pinp;
29     maxprofit: MAXIMIZE Profit;
30 johnpye 786
31     METHODS
32    
33     METHOD default_self;
34 johnpye 789 L := 0.5;
35     Inp := 0.5;
36 johnpye 786 END default_self;
37    
38     METHOD specify;
39     END specify;
40    
41     METHOD values;
42 johnpye 788 L.lower_bound := L0;
43     P.lower_bound := 0;
44     Out.lower_bound := 0;
45 johnpye 789 Inp.lower_bound := -0.001;
46 johnpye 786 END values;
47    
48     METHOD on_load;
49     RUN default_self;
50     RUN specify;
51     RUN values;
52     END on_load;
53    
54     METHOD self_test;
55 johnpye 788 ASSERT abs(L - 0.295686) < 0.000001;
56     ASSERT abs(Inp - 0.295686) < 0.000001;
57     ASSERT abs(Out - 0.632019) < 0.000001;
58     ASSERT abs(P - 1.683990) < 0.000001;
59 johnpye 786 END self_test;
60    
61     END testconopt;

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