# Beyond Algorithms and Optimization: Helping Students to Work and Think Like Engineers

By Alwyn Hoffman, North-West University

Undergraduate engineering students are capable of solving much more complex problems than we give them credit for. I found this to be true in my Algorithms and Optimization course, where students solve optimization problems that require them to determine what tradeoffs have to be made to satisfy conflicting requirements and arrive at a viable solution.

While the problems I assign can be readily understood—for example, helping a farmer decide what crops to plant to maximize profits—they are too complex to solve analytically without an appropriate toolset. Students must integrate the concepts they’ve learned in first-year engineering courses with programming skills to develop a mathematical solution, translate it into code or a model, and then display and interpret the results.

MATLAB® and Simulink® make it possible for students to tackle problems of this complexity in one semester. Instead of focusing on low-level implementation details at the component level, they can use built-in functions and blocks to develop solutions that would take them up to 10 times longer in languages like Python, C, or C#.

## Introducing Programming in MATLAB

Students in Algorithms and Optimization have already taken introductory programming, but most are new to MATLAB. To familiarize them with the MATLAB language and development environment, the first assignment asks them to build a simple user interface (Figure 1). The interface incorporates animated, multicolor graphs of sample data, which engage the students more than static charts. The entire exercise gives them confidence in their ability to build an application—one they at first thought complicated—by following a straightforward process.

The first major assignment is a nonlinear optimization problem to be solved in MATLAB. In each of the three years that I’ve taught the course, I’ve presented a different problem. This year, it was the farming problem: The students had to determine how much land should be allocated to each of two crops to maximize profits, given an expected amount of rainfall and electricity costs to run irrigation pumps. Last year, the students had to optimize an energy management system to find the optimal mix of grid, solar, and wind power production. The year before that, I gave them a mining scenario in which they had to find the lowest-cost method of operating and ventilating a mine with a combination of diesel- and electric-powered load-haul-dump (LHD) equipment and ventilation fans.

Each of these scenarios is easy to understand conceptually, but none has an obvious mathematical solution. Students first translate the verbal description of the problem into a set of equations. They must then determine which nonlinear programming techniques to use and implement a solution in MATLAB. Finally, they generate a solution to the non-linear optimization problem and pass this on to Simulink to visualize how this solution will perform in different practical scenarios.

For the next assignments, the students learn how to solve dynamic optimization problems in Simulink, reworking their initial MATLAB solutions to handle parameters that vary over time. In the farming problem, for example, instead of assuming a constant rate of rainfall based on a seasonal average, the students must now consider rainfall amounts that vary day by day. They develop Simulink models in which rainfall, wind speed, cloud cover, and other environmental variables are simulated using randomly generated values within a predetermined range (Figure 2). They incorporate the MATLAB code from the earlier assignment as user-defined function blocks, and then refine the code and model until they find a solution that works for different sets of dynamic conditions.

To develop their models, students must first build individual components and then figure out how to combine them into a complete system. I encourage them to test early and frequently rather than waiting until the entire system is assembled. I also show them how they can use Simulink Scope blocks to plot signals at any point in their model and trace errors back through the system, just as an engineer would when debugging a real-world system (Figure 3).

## Working Like Engineers

While I encourage students to complete as much of the final assignment as they can by themselves, I also allow them to work in groups. Even if they choose to work together, however, every student must hand in their own assignment and be able to explain to me how each line of MATLAB code works. I tell my students that it is perfectly acceptable to incorporate partial solutions from others as long as you fully understand those solutions and how they operate. Some instructors do not agree with allowing students to include the work of their classmates, but I believe that my approach reflects the way engineers work in the real world—most engineers have neither the time nor the resources to solve every problem from scratch.

I recently began teaching a fourth-year course on data analytics in which students use MATLAB to complete more advanced assignments. I based these assignments on my own research and on thesis papers written by my post-graduate students. I broke down the data analysis into three stages. In the first stage, students perform simple statistical explorations and visualizations of the data. Next, they apply statistical measures to see how various subsets of data differ from one another. Finally, they build regression, neural network, and decision tree models and use them to make predictions based on the data.

The students had six weeks to complete their examination assignments. In the first few weeks, one student visited me several times during office hours with questions about how to proceed. I found out that this student shared what he had learned from me with his classmates—he was acting as a kind of senior engineer or lead engineer working with junior engineers on a real project. Almost every student in the class completed their assignments and did well. These results confirmed to me, and proved to them, a core principle for today’s engineers: You can think through and solve difficult engineering problems when you have the right tools and know how to use them.

North-West University is among the nearly 1300 universities worldwide that provide campus-wide access to MATLAB and Simulink. With a Campus-Wide License, researchers, faculty, and students have access to a common configuration of products, at the latest release level, for use anywhere—in the classroom, at home, in the lab, or in the field.