The output of the optimization(using GEKKO) is giving zero for the manipulated variable(IMODE=6)

Viewed 53

I am trying to implement a level 2 self driving car using gekko optimization tool. I am using MODEL PREDICTIVE CONTROL a control strategy to control the car .So in gekko ,I have chosen IMODE =6.

The delta_throttle and the delta_steering_angle are the manipulated variables(MV's). These variables are the input to the car.

The gekko should solve and provide the value for those variables thus making the car move autonomously .

But unfortunately ,the software is just returning a zero value for both the variables. I dont know why the software is providing zero.It should have provided a non zero values so that the car could have moved.

Can anyone help me out ? THANKS!!!

1 Answers

Here are three things to check:

  1. The solver reports a successful solution. The solution status can be checked with:
if m.options.APPSTATUS==1:
   print('Successful Solution)
else:
   print('Unsuccessful')

The solution status is also displayed when disp=True in m.solve(disp=True).

  1. The Manipulated Variable status is on.
delta_throttle.STATUS = 1
delta_steering_angle.STATUS = 1
  1. The Controlled Variable status is on such as for velocity and position.
velocity.STATUS = 1
position.STATUS = 1

Here is a velocity MPC application for reference:

MPC for velocity control

from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt

m = GEKKO()
m.time = np.linspace(0,20,41)

# Parameters
mass = 500
b = m.Param(value=50)
K = m.Param(value=0.8)

# Manipulated variable
p = m.MV(value=0, lb=0, ub=100)
p.STATUS = 1  # allow optimizer to change
p.DCOST = 0.1 # smooth out gas pedal movement
p.DMAX = 20   # slow down change of gas pedal

# Controlled Variable
v = m.CV(value=0)
v.STATUS = 1  # add the SP to the objective
m.options.CV_TYPE = 2 # squared error
v.SP = 40     # set point
v.TR_INIT = 1 # set point trajectory
v.TAU = 5     # time constant of trajectory

# Process model
m.Equation(mass*v.dt() == -v*b + K*b*p)

m.options.IMODE = 6 # control
m.solve(disp=False)

# get additional solution information
import json
with open(m.path+'//results.json') as f:
    results = json.load(f)

plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',label='MV Optimized')
plt.legend()
plt.ylabel('Input')
plt.subplot(2,1,2)
plt.plot(m.time,results['v1.tr'],'k-',label='Reference Trajectory')
plt.plot(m.time,v.value,'r--',label='CV Response')
plt.ylabel('Output')
plt.xlabel('Time')
plt.legend(loc='best')
plt.show()
Related