Back to list

Tech Blog · Algorithms Explained

[Prescription Methods 5] AI that learns by trial and error: can it work in a factory? — Reinforcement learning

Reinforcement learning, so successful in Go and games, learns from millions of trials. We explain why it cannot be used as is in a factory, and why offline reinforcement learning, which learns only from past operating data, must be wary of actions that are not in the data.

Jul 23, 2026 · OPTI-X

Series “Prescription Methods” · Part 5

Reinforcement learning is a method that acts, observes the result (the reward), and learns better actions. In Go and video games, it has learned rules for acting that surpass humans. So why is it rare in factories?

How it works: long-term value over immediate reward

Sutton and Barto's textbook (2018) defines reinforcement learning as "learning what to do—how to map situations to actions—so as to maximize a numerical reward signal." The learner is not told which actions are right; it must discover them by trying. The authors name trial-and-error search and delayed reward as the two features that set reinforcement learning apart from other kinds of learning.

There are four elements: the policy, the rule for choosing an action in a given state; the reward, which signals what is good or bad at each moment; the value, an estimate of the total reward to be received from that state onward; and, optionally, a model of the environment. Actions are chosen by value, not by reward. A state with low immediate reward can still have high value if good states tend to follow it.

One step of reinforcement learning

The agent learns the rule for choosing actions (the policy) that maximizes reward

  1. 1
    Observe the stateRead the process state (temperature, concentration, flow rate, etc.)
    Next
  2. 2
    Choose an actionPick a manipulated value according to the policy
    Next
  3. 3
    Receive reward and learnHigh reward if the result is close to the goal; the policy is adjusted little by little
    Repeat and improve the policy

Worked example: chemical dosing in a neutralization tank

One of the first examples in the textbook is itself a process: an adaptive controller that adjusts a petroleum refinery's operation in real time, optimizing the yield/cost/quality trade-off without sticking strictly to the setpoints engineers originally suggested. Let us carry the same structure over to a smaller process.

Suppose a neutralization tank uses the inflow's pH and flow rate and the current dosing as the state, and chooses the next dosing as the action. The reward reflects both the gap from the target pH and the chemical cost. Adding a lot of chemical moves the pH toward target quickly, but if the process responds with a delay, it may overshoot the target a few minutes later. Delayed consequences like this are why the agent learns value.

To find a better dose, it also has to try doses it has not tried yet. The textbook describes this as the exploration–exploitation dilemma. Choosing only actions that have worked before means never finding better ones; trying only new actions means never collecting reward. When results are stochastic, the same action must be tried many times before its effect can be trusted.

The problem is the number of trials

In games, trials are free. In a case described in the textbook, AlphaGo Zero learned from 4.9 million games of self-play over about 3 days. DQN, which learned Atari games, used 50 million frames per game, about 38 days of experience.

In a factory, a single wrong attempt becomes defects, equipment damage or a safety incident. Dulac-Arnold et al. (2019) list what real systems have in common: good simulators are rare, systems are stochastic and change over time, safety constraints are strong, and running them is expensive and slow. That is why there are two broad ways to use reinforcement learning in a process: trial and error inside a simulator, or learning only from operating data that has already been collected.

Online vs. offline reinforcement learning

In a factory, the right-hand column is the realistic starting point

Online (trying directly)
Offline (past data)
Data
Generated directly during learning
Operating history already collected
Risk on the floor
The attempts themselves are risky
Equipment is not touched during learning
What it needs
An accurate simulator
Data that records manipulations and results together
Core challenge
The gap between simulator and reality
Overestimating actions not in the data

The simulator route is not easy either. Sutton and Barto write that most current applications learn policies from simulated experience, yet point out that simulating real-world experience with enough fidelity is difficult and sometimes impossible.

The trap of offline reinforcement learning

Levine et al. (2020) sum up the limits of offline reinforcement learning in two points. First, it cannot explore: if the data contain no region where results were good, there is no way to find it. Second, a better policy has to act differently from the data, so the model must answer "what if we had done this?" questions about things it has never seen.

The trouble is that optimization exploits this weakness. Because the policy is trained to pick actions with high estimated value, it picks exactly those out-of-data actions whose value is wrongly estimated as high. Online, the agent would try them and find out they are wrong; offline, the errors accumulate with every training iteration. Remedies fall into two groups: constraining the learned policy to stay close to past operating behavior, and using the uncertainty of value estimates to detect when it leaves the data.

Conservative Q-learning (CQL) took another route. It pushes down the value of actions the policy wants to pick and pushes up the value of actions in the data, so that it estimates the policy's value lower than the true value (a lower bound). The gap was largest on data mixing several policies. The authors expected such data to be more common in real problems.

Performance on data mixing several policies

D4RL hopper-mixed, normalized score (average of 4 runs)

BRAC-v (policy constraint)
0.8
SAC (standard RL applied offline)
3.5
BC (imitating past behavior)
11.8
BEAR (policy constraint)
25.3
CQL
48.6
Source: Kumar et al. (2020), Table 1

In the same paper, the ensemble-minimum method, an existing way to prevent overestimation, estimated policy values thousands to tens of trillions above the true values. CQL estimated values below the true values on all three tasks.

The authors also stated its limits. A rigorous theoretical analysis with deep neural networks is left for future work, and like supervised learning it can overfit, yet there is still no simple way to decide when to stop training.

What to check when applying it to a process

Dulac-Arnold et al. present nine challenges for putting reinforcement learning into real systems: learning only from past logs, few samples, high-dimensional continuous states and actions, safety constraints that should never or rarely be violated, partial observability, rewards that mix several objectives, explainable policies, real-time inference within the control cycle, and delays in actuators, sensors and rewards. They also recommend evaluating the worst case rather than the average reward, and examining the components of the reward separately.

The authors treat the first training data as logs left by operators or an existing controller. How varied the manipulations in those logs are sets the starting point.

What to check when using reinforcement learning in a process

Questions that come before choosing an algorithm

DataIs the history of manipulations varied enough?
If you always operated at the same values, there is little to learn
RewardHave you defined the goal as a number?
If it looks only at quality, it can learn a policy that overuses chemicals
SafetyDon't trust the learned policy as is
Allowed-limit checks before execution, and staged rollout

On reward design, the textbook is clear. The reward is the way to communicate "what you want achieved," not "how you want it achieved." Rewarding subgoals can lead the agent to find ways of meeting the subgoals without meeting the real goal, and some of the unexpected ways it finds to earn reward can be dangerous.

How it relates to other methods

MPC in Part 3 calculates ahead with a process model every cycle to decide its moves. Reinforcement learning learns a policy from states to actions through experience, and at run time mostly uses that policy to choose actions. The textbook distinguishes methods that use a model to think through the future (planning, model-based) from methods that learn purely by trial and error (model-free), and explains that modern reinforcement learning spans the whole range between them.

Where Bayesian optimization in Part 4 picks conditions for one experiment at a time, reinforcement learning handles sequences of decisions whose results appear late. The problem of offline reinforcement learning being wary of out-of-data actions shares its roots with the extrapolation problem of surrogate-based optimization in Part 7.

In a factory, reinforcement learning starts from a simulator or past data, and must not rate highly actions the data do not support. In the next part, we look at a search method that imitates biological evolution: evolutionary algorithms.

References

Could this work for your process?

Talk to us