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; 
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's gravatar image

accept rate: 0%

In your particular implementation, you didn't specify the initial value (x[0]) 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[0] 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's gravatar image

Gilead ♦
accept rate: 15%

edited 08 Jun '13, 10:53

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%20Rubin's gravatar image

Paul Rubin ♦♦
accept rate: 19%

edited 08 Jun '13, 23:16

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • 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



Asked: 08 Jun '13, 09:33

Seen: 1,816 times

Last updated: 08 Jun '13, 23:16

OR-Exchange! Your site for questions, answers, and announcements about operations research.