Migrating from AMPL to Pyomo
Question: I am trying to use open source Pyomo lib instead of ampl, so i am trying
migrating the ampl car problem that comes in the Ipopt source code tarball as
example, but i am having got problems with the end condition (reach a place
with zero speed at final iteration) and with the cost function (minimize final
time).

The code below states the dae system:

    
    
    # min tf
    # dx/dt = 0
    # dv/dt = a - R*v^2
    # x(0) = 0; x(tf) = 100
    # v(0) = 0; v(tf) = 0
    # -3 <= a <= 1 (a is the control variable)
    
    #!Python3.5
    from pyomo.environ import *
    from pyomo.dae import *
    
    N = 20;
    T = 10;
    L = 100;
    
    m = ConcreteModel()
    
    # Parameters
    m.R = Param(initialize=0.001)
    
    # Variables
    def x_init(m, i):
        return i*L/N
    
    m.t = ContinuousSet(bounds=(0,1000))
    m.x = Var(m.t, bounds=(0,None), initialize=x_init)
    m.v = Var(m.t, bounds=(0,None), initialize=L/T)
    m.a = Var(m.t, bounds=(-3.0,1.0), initialize=0)
    
    # Derivatives
    m.dxdt = DerivativeVar(m.x, wrt=m.t)
    m.dvdt = DerivativeVar(m.v, wrt=m.t)
    
    # Objetives
    m.obj = Objective(expr=m.t[N])
    
    # DAE
    def _ode1(m, i):
        if i==0:
            return Constraint.Skip
        return m.dxdt[i] == m.v[i]
    m.ode1 = Constraint(m.t, rule=_ode1)
    
    def _ode2(m, i):
        if i==0:
            return Constraint.Skip
        return m.dvdt[i] == m.a[i] - m.R*m.v[i]**2
    m.ode2 = Constraint(m.t, rule=_ode2)
    
    # Constraints
    def _init(m):
        yield m.x[0] == 0
        yield m.v[0] == 0
        yield ConstraintList.End
    m.init = ConstraintList(rule=_init)
    
    '''
    def _end(m, i):
        if i==N:
            return m.x[i] == L amd m.v[i] == 0
        return Constraint.Skip
    m.end = ConstraintList(rule=_end)
    '''
    
    # Discretize
    discretizer = TransformationFactory('dae.finite_difference')
    discretizer.apply_to(m, nfe=N, wrt=m.t, scheme='BACKWARD')
    
    # Solve
    solver = SolverFactory('ipopt', executable='C:\\EXTERNOS\\COIN-OR\\win32-msvc12\\bin\\ipopt')
    results = solver.solve(m, tee=True)
    


Answer: Currently, a ContinuousSet in Pyomo has to be bounded. This means that in
order to solve a minimum time optimal control problem using this tool, the
problem must be reformulated to remove the time scaling from the
ContinuousSet. In addition, you have to introduce an extra variable to
represent the final time. I've added an example to the [Pyomo github
repository](https://github.com/Pyomo/pyomo/blob/master/examples/dae/car_example.py)
showing how this can be done for your problem.

