Continuous manufacturing: Better soap with Bonsai

Bonsai gives you tools to build, train, and deploy AI brains. Extrusion, a common process for soap making, is one possible use case for brains in the world of continuous manufacturing. The extrusion process heats material in an extrusion screw then forces it through a hole at the end to press it into the preferred shape.

Sample extrusion infographic


Contoso Soaps

Contoso Logo

The Contoso Consumer Products division includes Contoso Soaps, which uses extrusion to produce thousands of tons of soap per year.

The Contoso engineers believe they can improve product yield up to 15%, especially during the line changeovers. Contoso executives are willing to invest in improvements, but want to know the suggested changes will work.

Contoso uses an industry proven advanced process control (APC) system combined with expert operators to control the extrusion process. The operators pass supervisory commands to the APC system to implement control strategies. The APC system adjusts the line equipment based on the control strategy.

The control system can set:

  • the speed of the screw.
  • the temperature in different zones of the screw.
  • the opening of the hole where soap material exits.

Each control parameter must be tightly controlled to produce soap that meets Contoso quality specifications.

Limitations of current control methods

Soap making is a complex chemical process and difficult to control. Describing and predicting what happens to the soap inside the extruder is particularly challenging. The process is also dynamic and control methods change depending on the type of soap being made. For example, when changing over from making more oily soaps to dryer soaps, or when changing soap color. Other sources of manufacturing variability include:

  • quality changes in the raw materials.
  • mechanical wear of the extruder components.
  • soap residue left in the extruder from previous runs.

Advantages of Bonsai brains

Bonsai brains provide improved control methods because they learn by practicing on the problem they need to solve. The Contoso engineers want a brain that:

  • automatically signals their APC system.
  • adapts quickly to production changeovers.
  • applies short-term process changes when the extruder becomes coated with soap over multiple runs.
  • applies long-term process changes as extruder equipment wears.

The table below highlights the primary ways the Contoso extruder brain would improve on the existing control system.

  Dynamic Icon Competing Icon Question Icon
  Dynamic / Highly Variable Systems Competing Goals or Strategies Unknown Conditions
Current control system Only controls a narrow range of scenarios No trade-off between goals and strategies Unresponsive to unknown inputs and changing system behavior
Brains Adapts to a wide range of scenarios Learns and trades off between multiple strategies Learns strategies for unexpected input and changing behavior

Brains can also help Contoso operators and engineers improve manual extruder control by advising operators (on the line or in the control room) instead of controlling the extruder directly. Contoso will start by having their brain advise operators in the control room. If the brain does well, the engineers plan to let the brain autonomously control less critical work so the operators can focus on more crucial control decisions.

Designing the Contoso extruder brain

When the Contoso engineers, operators, and data scientists meet to design their Bonsai brain, they start by defining the problem they want to solve. They rely on their experience with the current system to identify useful control strategies. Then they translate their strategies into Inkling code that Bonsai uses to train their brain.

Step 1: Define actions that the brain controls

The key actions that the brain will control for an extruder are the screw speed, the zone temperatures, and the size of the hole at the end.

Step 2: Identify control strategies the brain will learn

Brains can start by learning existing control strategies, then combine them in new ways to generate responsive strategies for controlling the extruder. After some discussion, the Contoso team comes up with the following strategies:

Problem Cause Response
Soap chunks outside the extruder Oily soap was heated incorrectly Modify heat
Throughput drops for dry soap Screw is configured for oily soap Modify heat and screw speed

Step 3: Decide on implementation strategies

The team decides that the screw temperature needs to be controlled separately from the extruder hole to get good quality soap during changeovers. The team also decides that they should train two control strategies:

  • Strategy 1 will be for oily soap.
  • Strategy 2 will be for dry soap.

Lastly, the team decides that the definition of oily and dry is fuzzy because it changes for different soap colors and process conditions. So the brain will need to learn against a wide set of inputs for each strategy.

Step 4: Create a training simulation

Brains learn by practicing iteratively in simulation. The Contoso team meets with their simulation experts to decide if they can adapt their existing simulator to respond iteratively to brain instructions.

They decide they can convert their existing simulator to a training simulator. When they finish modifying the simulator, the engineers add it to their Bonsai workspace using the Simulator API. During training, Bonsai will scale the simulation model in the cloud and use it to generate input states for their machine teaching plan.

Contoso Soap extruder brain design

The following diagram illustrates the final extruder brain designed by the Contoso team. The design is modular and includes:

  • two learned strategies (Oily Soap and Dry Soap).
  • a selector to determine when each strategy is appropriate.

Technical diagram of final brain


After training, the team can export their brain and add it to their control process. Like their old system, their new brain knows how to apply current operational strategies. But, unlike their old system, their brain also knows how to combine those strategies in new ways and automatically respond to changes in the extruder.