The system we designed consists of 3 primary subsystems, each containing a variety of arrays, mathematical functions, MATLAB Scripts, and additional subsystems that allow the total system to function. We originally intended to use optimization to force the system to achieve the objective of the user, but we have been limited by the abilities of MATLAB and Simulink to properly perform continuous optimization. The system is designed in a way that optimization could easily be implemented if the proper tools existed in Simulink. At the end of this page, we will detail our failed attempts at getting optimization to work properly. Our first image shown below are the 3 primary subsystems. From the left: vehicle information, motion dynamics, and lastly kinematics. 

Vehicle Information

Our Simulink model has been designed to function with either a coupe, sedan, or an SUV. We chose example vehicles for each of the vehicle types and specified the corresponding information. We selected either 1, 2, or 3, which corresponds to values within an array inside of the Static Input Block. 1 references the coupe, 2 references the sedan, and 3 references the SUV. This value was also fed into the motion dynamics block to select the appropriate vehicle acceleration that we were testing. Pictured below is the interior of the 
Static Input Block

It was named as such because the values within this array would not change with the system and remained constant. The commented out line details what each value in the array corresponds to, and these values became important in the kinematics block that we will discuss later. The values came from manufacturer specifications for the cars listed. We chose these vehicles as to have a decent cross-section of vehicles from the perspective of acceleration, power, and drag. The 1, 2, or 3 simply selects between these arrays. 

Motion Dynamics

This subsystem is likely the single most important subsystem in the entire model. The only input into the model is the selection of what vehicle is being used so it can correspond with the correct acceleration. 

The outputs of the model are the requested velocity, and the actual velocity. This portion functions similar to a cruise control, we specified the different velocity we wanted the vehicle to move at and the closed loop system dynamics portion that contains both the Gasoline and the Electric system dynamics responded accordingly to how a cruise control would respond. Pictured here is the velocity variation we tested at.

The velocity changes are plotted with m/s on the y-axis. This signal generator could obviously have any velocity set into its input, but we felt this variation of velocity to show a good range of positive and negative acceleration. 

From this block, the requested velocity got split to head to either the electric or gasoline engines. Prior to the system dynamics blocks the signal had to be fed through a gain block which represented the utilization of either engine. Despite the fact that gasoline engines do not function on a linear 0 to 100 scale, for the purposes of our model we made this assumption.

Both sides of this split could be between 0 and 1, meaning the maximum utilization would be 100% usage of both engines: a value much higher than you would ever realistically need. This value then gets fed into the 2 different engine dynamics blocks which have a second input: road grade. The Steepness of roads in the United States are quantified by the gradient of the road. The type of Simulink block that was used to set the requested velocity is the same as the block that was used to set the road grade so we will not display another image, but this was how it was varied for the purposes of our experimentation. The gasoline system dynamics are pictured below.

The Electric system dynamics would be identical with the exception of there would be no selector for the vehicle types. The first transfer function operates as a PI controller that was tuned to respond in a m/s timeframe. The MATLAB Function block functions as a gain block that can switch between different gains as specified by vehicle type. The Middle transfer function works in terms of newtons which allows road grade to be factored in following its inclusion, it works relative to engine throttle position. The last transfer function helps adjust for any sudden changes that may be incurred because of a change in road grade, or maybe a shift in wind direction. The adjusted value leaves the specific engine dynamics and is combined with the other engine dynamics. The output of this system is shown in a scope below and represents a normal system response with reasonable overshoot. This was run with 50% utilization of both engines. 

Kinematics

The final subsystem that was properly completed is the kinematics system. The inputs of this system are both the actual, and requested velocity from the Motion Dynamics Subsystem, as well as the static inputs, and the requested objective. 

The inputs feed into the kinematics block which converts both the actual and the ideal car velocities at all points in time to watts and it considers drag and rolling resistance against the vehicle and finds the amount of energy required to overcome it at the specified velocity. The Actual MATLAB Function is shown to the right. The equation converts the velocity into power shown in Watts. Watts are defined as Joules/second and the integral of the wattage output when multiplied by 1/60 gives us joules being used. Whereas the derivative of this signal lends us to be able to observe when the system is in flux and is experiencing a change in acceleration. We ended up bringing in more variables than we needed into the Engine Coefficients MATLAB Function, but the reasoning behind this was we believe MATLAB and Simulink would work together better than they did. The below code is shown as we have at the end, when we realized we had to test on our own, but the entire system is designed in a way that optimization SHOULD be simple if the programming within MATLAB worked properly. 

Inside of here we consider the efficiency of gasoline engines in turning gasoline into usable energy in contrast to electric engines. The electric engine is shown to be considerably more efficient. This code calculates the usage of energy.

Attempted Optimization

Our first attempt at optimization was within this function block and using a linear Simplex Optimization solver. The issue arose that this function was not able to backlog the information and could not solve at the rate at which information was fed through. We considered generating the data and then running the solver on the data, but for the solver to function properly it needs to be able to change the decision variables -both engine utilizations- and that did not work properly when the solver could not attempt to vary those variables.

The second attempt at optimization was embedded in Simulink. You may have noticed earlier within the Motion Dynamics Subsystem there was a block we did not explain that was an optimizer meant to optimize for certain transient conditions and actually functioned as intended. When feeding in the signal from motion dynamics and allowing this solver to vary the previously specified decision variables we were able to generate utilization numbers that corresponded and created appropriate transient conditions. We were also able to specify constraints that COULD be used to optimize for acceleration, towing capacity, or fuel efficiency. We were able to maximize or minimize any output function by varying the decision variables. We could have hooked up this optimization solver to the Engine Coefficients MATLAB Function and minimized gallons of gas used to optimize fuel efficiency, or maximized the kilowatts output. The intrinsic problem with this solver is that it is not continuous: it would output a single value for each engine utilization and not a new value for every second. If this one tiny caveat were different our system could easily optimize for any variable considered.