# Differential equations/optimal control in AMPL

 0 Does someone has an experience in solving differential equations in AMPL? I googled a lot, but no suitable results... In google groups I've found a simple "hand-made" example, but it doesn't work... So, this example I found. Consider this ODE: x' = -ax + u, x(0) = 0.  where a=0.2 is a parameter; x = state variable, between 0 and 9; u = input variable, between 0 and 5. You can write this in AMPL as follows (using textbook forward Euler): param N := 10; # no. of integration steps param dt := 0.01; # integration step size param a := 0.2; set kset ordered := 0..N; var x{kset}, >= 0, <= 9; var u{kset}, >= 0, <= 5; minimize obj: 0; subject to c1{k in 1..N}: (x[k] - x[k-1])/dt = -a*x[k-1] + u[k-1]; option solver ipopt; solve; display x, u;  The solution gives me zeros for u and x... It is no wonder because of this line minimize obj: 0;  As far as I understood we need to represent the problem as a system of algebraic equations, but what will be a goal function in this case??? So, can somebody give any suggestions or proper examples? Thanks in advance. asked 08 Jun '13, 09:33 magneton_bora 1●1 accept rate: 0%

 1 In your particular implementation, you didn't specify the initial value (x) and the inputs (u[k]), so the problem is under-defined. Fix those degrees-of-freedom and you will get the solution to the ODE. And if you're finding the optimal input vector, then fix the x and use a objective function (that isn't just the feasibility objective 0), and you will get some answer for u[k]. answered 08 Jun '13, 10:35 Gilead ♦ 2.3k●5●14 accept rate: 15%
 0 As an example, consider the old Lunar Lander game. Your state consists of altitude, vertical velocity and fuel (plus mass in some versions). Your control variable is burn rate (which translates to thrust). The terminal condition is (hopefully) altitude zero with velocity zero. Possible objective functions are minimizing fuel burned or minimizing time to landing. answered 08 Jun '13, 23:15 Paul Rubin ♦♦ 14.6k●5●13 accept rate: 19%
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×190
×29
×8