REQUIRE "atoms.a4l"; IMPORT "johnpye/conopt/conopt"; (* This example model comes from the CONOPT documentation, which is distributed with CONOPT. *) MODEL conopttest; Profit, Inp, Out IS_A solver_var; P, L IS_A solver_var; K IS_A real_constant; Al, Ak, Ainp, Rho IS_A solver_var; Pinp, P0, D IS_A real_constant; W, L0, K0 IS_A real_constant; cesfn: Out = ( Al*L^(-Rho) + Ak*K^(-Rho) + Ainp*Inp^(-Rho) )^(-1/Rho); demandfn: Out = ( P0 - P ) / D; W :== 1.0; L0 :== 0.1; Pinp :== 1.0; K0 :== 4.0; P0 :== 2.0; D :== 0.5; K :== K0; profitfn: Profit = P*Out - (L-L0)*W - Inp*Pinp; maxprofit: MAXIMIZE Profit; METHODS METHOD default_self; L := 0.5; Inp := 0.5; END default_self; METHOD specify; FIX Al, Ak, Ainp, Rho; END specify; METHOD values; Al := 0.16; Ak := 2.00; Ainp := 0.16; Rho := 1.0; L.lower_bound := L0; P.lower_bound := 0; Out.lower_bound := 0; Inp.lower_bound := -0.001; END values; METHOD on_load; RUN default_self; RUN specify; RUN values; END on_load; METHOD self_test; ASSERT abs(L - 0.295686) < 0.000001; ASSERT abs(Inp - 0.295686) < 0.000001; ASSERT abs(Out - 0.632019) < 0.000001; ASSERT abs(P - 1.683990) < 0.000001; END self_test; END conopttest;