/* Dynamical Optimization in Picat. From http://www.dcsc.tudelft.nl/%7Eahuesman/Ampl.pdf (solution page 8) http://www.dcsc.tudelft.nl/~ahuesman/ Solves the problem min u(t) int(x dt, 0,10) s.t. dx/dt = -x(t) + u(t) x(0) = 1 x(10) = 5 0 <= u(t) <= 10 Translation of the AMPL model. From the documentation """" DOP1.mod - Simple problem to test dynamic optimization in AMPL format Adrie Huesman 27/11/2004 Problem taken from "Research note: Solving and optimization of ODE.s" SETS no set declaration necessary! """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. import mip. main => go. go => Ng = 101, Dt = 0.1, % (10 - 0)/(Ng - 1) X = new_list(Ng), X :: 0.0..10.0, U = new_list(Ng), U :: 0.0..10.0, % Cost :: 0.0..1000.0, foreach(J in 1..Ng-1) % (X[J+1] - X[J])/Dt #= -X[J+1] + U[J+1] (X[J+1] - X[J]) #= (-X[J+1] + U[J+1])*Dt end, % implicit Euler approximation X[1] #= 1.0, % initial condition X[Ng] #= 5.0, % end condition Cost #= sum(X), solve($[min(Cost)], X ++ U), println(cost=Cost), println(x=X), println(u=U), nl.