- Front Matter
- Preface
- Chapters
- 1 · The Control Problem You Already Know
- 2 · Agent, Environment, Reward
- 3 · The Digital Twin as a Training Ground
- 4 · Making the World Discrete: States and Actions
- 5 · The Q-Table: A Number for Every Choice
- 6 · Learning by Trial and Error
- 7 · Explore or Exploit
- 8 · Watching It Learn
- 9 · Reading the Learned Policy
- 10 · From Policy to Advice
- 11 · Implementation in C# and MS SQL
- 12 · Operational Lessons and Honest Boundaries
- Appendices
- A · Glossary of RL Terms
- B · The Q-Learning Update, Step by Step
- C · SQL Schema for the Q-Table and Episode Log
- D · Using the NEXUS-1 Optimization (RL) Screen
- E · Beyond Q-Learning: Other Approaches
- F · C#/.NET Developer Quickstart
- G · References & Further Reading
- Back Matter
- Index
From Trial to Policy
Minimum price
$89.99
$119.99
You pay
Author earns
About
About the Book
Power is drifting below target.
An operator can correct it. A conventional controller can correct it. A page of carefully tuned if-rules can probably correct it too.
But what happens when the operating conditions change, the assumptions behind those rules begin to break down, and the trade-off between accuracy, stability, and actuator wear becomes too complex to tune by hand?
And now there is a new temptation: hand the problem to a machine-learning model and let it learn for itself.
It will produce recommendations.
It may even produce excellent recommendations.
But if the recommendation affects a control system, one question matters more than all the others:
Can you explain exactly why it chose that action?
From Trial to Policy is written around a single governing principle:
The agent learns, the engineer understands.
This book shows how to build a reinforcement-learning agent that remains completely readable after training. No hidden layers. No black-box neural network. No mysterious weights distributed across millions of parameters. The result of learning is a simple, inspectable Q-table: a finite set of states, a finite set of actions, and a number describing the long-term value of each possible choice.
Every recommendation can be traced.
Every action can be explained.
Every learned policy can be read directly by a human.
The book takes reinforcement learning apart piece by piece and rebuilds it from first principles. Agent. Environment. Reward. State. Action. Exploration. Policy. Nothing is assumed, and nothing is hidden behind mathematical jargon. Each concept is mapped directly to C#, .NET, SQL Server, and a working industrial-style control problem.
Try the Live Console Now!
This is a hands-on companion to NEXUS-1, a fully interactive browser-based optimization console. No installation, no server, zero setup. Every state, action, reward curve, policy grid, and training result shown in the book comes directly from this live system.
Open the console, start training, and watch the policy emerge from thousands of episodes of trial and error.
👉 Play with the live console:
https://gregory82gr.github.io/Nexus-1-phase-0/
What's Under the Hood? (The Engineering Blueprint)
This is not a machine-learning theory book. It is the architecture of a working, interpretable reinforcement-learning system.
• The Control Problem — how a familiar feedback loop becomes a learning problem.
• Agent, Environment, Reward — the three building blocks of reinforcement learning, mapped directly to C# interfaces and classes.
• The Digital Twin Training Ground — why learning happens inside a fast surrogate model rather than on the real system.
• State and Action Design — turning a continuous world into 35 readable states and five discrete control actions.
• The Q-Table — the entire learned policy stored as 175 auditable numbers.
• The Learning Algorithm — Q-learning explained step by step, arithmetic by arithmetic, without requiring a machine-learning background.
• Exploration versus Exploitation — why an agent must sometimes try apparently bad actions in order to discover better policies.
• Policy Interpretation — reading the learned table directly and understanding why every decision was selected.
• Advisory Deployment — how a learned policy becomes operational advice while remaining bounded, inspectable, and human-approved.
• C# and SQL Server Implementation — complete architecture, persistence model, training workflow, reward logging, and policy storage.
How Every Chapter Is Structured
Every chapter follows the same engineering blueprint:
What You Already Know — connecting new reinforcement-learning concepts to familiar software-engineering ideas.
The Concept — a precise explanation of the mechanism and why it exists.
One Figure — a focused diagram illustrating the idea being discussed.
See It in NEXUS-1 — exactly where the concept appears in the live console.
Honest Boundary — a transparent discussion of limitations, assumptions, and what the demonstration genuinely does versus what it deliberately simplifies.
No magic.
No hype.
No claims that learning systems are smarter than they are.
Only mechanisms that can be inspected, explained, and reproduced.
👤 Who This Is For
If you are a C#/.NET developer, software architect, controls engineer, simulation engineer, or systems designer who has never studied reinforcement learning but wants to understand how a real learning agent works, this book is for you.
It assumes you are comfortable with software development and basic engineering reasoning. It assumes no prior knowledge of machine learning, neural networks, statistics, or control theory.
By the final chapter you will be able to open a policy table, inspect every learned action, and understand exactly how trial and error became a decision-making strategy.
This volume is the reinforcement-learning companion to NEXUS-1 and the third book in the companion series following From Grid to Core and From Flood to Cause.
Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης Γρηγόριος, Αγαθαγγελιδης Γρηγοριος, Grigorios Agathangelidis.
Feedback
Bundle
Bundles that include this book
The NEXUS-1 Series

7 Books
- Pricing
$449
Minimum priceBought separately$679.91Suggested price$799
Author
About the Author
My name is Grigorios Agathangelidis, and my professional background is in Electrical Engineering and Software Engineering. I am not a machine-learning researcher, artificial-intelligence scientist, control-theory academic, or specialist in reinforcement learning. The ideas presented in From Trial to Policy are not the result of formal AI research programs or industrial machine-learning deployments. Rather, they emerged from independent study, practical software-engineering experience, and a desire to understand how learning systems make decisions.
This book grew naturally from the NEXUS-1 project. While From Grid to Core explored the architecture of a digital-twin platform and From Flood to Cause examined deterministic reasoning and root-cause analysis, this volume turns to a different question: how can a system learn from experience while remaining understandable to the engineers responsible for it?
My interest in reinforcement learning began not with artificial intelligence itself, but with a broader engineering concern. Modern systems increasingly rely on algorithms that adapt, optimize, and recommend actions. Yet many of these systems become more difficult to understand as they become more capable. Engineers are often asked to trust outputs they cannot fully inspect. I wanted to explore whether learning and transparency could coexist, and whether a useful learning system could remain simple enough to be understood rather than merely trusted.
Although the examples in this book are drawn from a nuclear-inspired digital twin, the underlying ideas extend far beyond that domain. Any system that must make decisions under uncertainty faces similar challenges: balancing competing objectives, adapting to changing conditions, learning from feedback, and explaining why one action was preferred over another. These challenges appear in industrial automation, robotics, logistics, finance, energy systems, transportation, and modern software platforms.
Throughout this work I have tried to connect disciplines that are often presented separately: reinforcement learning, control systems, simulation, digital twins, software architecture, observability, explainability, and operational decision support. My goal has not been to present reinforcement learning as a mysterious branch of artificial intelligence, but rather as a practical engineering technique that can be understood through familiar concepts such as feedback loops, lookup tables, state machines, and optimization.
A central theme of this book is that interpretability is not a luxury; it is an engineering requirement. The reinforcement-learning agent presented here does not produce decisions through millions of hidden parameters. Instead, it learns a finite policy represented by a readable Q-table that can be inspected, challenged, audited, and discussed. Whether this specific implementation is ultimately useful is less important than the principle behind it: that learning systems should remain understandable to the people who build, operate, and maintain them.
The algorithms, architectures, and examples presented throughout this book are educational and illustrative in nature. They are intended to demonstrate engineering concepts and implementation approaches rather than provide certified control solutions. The digital twin used for training is a simplified surrogate model, and the learned policy operates in an advisory context. Nothing in these pages should be interpreted as a validated control strategy for any real industrial facility.
What interests me most is the relationship between learning and understanding. How does experience become knowledge? How does a collection of observations become a policy? How can a decision made by a machine remain visible, explainable, and accountable to a human operator? These questions sit at the intersection of software engineering, systems thinking, simulation, and artificial intelligence, and they continue to shape my work.
From Trial to Policy is therefore not only a book about reinforcement learning. It is also an exploration of a broader engineering philosophy: that automation should remain understandable, that optimization should remain auditable, and that human judgment should remain central even when machines assist in the decision-making process.
The ideas presented here represent a snapshot of an ongoing learning journey. Reinforcement learning is a rapidly evolving field, and many approaches more sophisticated than the one described in this book exist today. Some assumptions will evolve, some implementations will improve, and some conclusions may change as understanding grows. That is not a weakness of engineering; it is one of its strengths. Progress comes from continual refinement, experimentation, and the willingness to question our own models.
If there is a single message I hope readers take away from this work, it is that learning systems do not have to be opaque to be useful. In many situations, a simple and understandable policy can be more valuable than a more powerful system whose reasoning cannot be inspected. Understanding remains a feature, not a limitation.
Above all, this book reflects a belief that curiosity, disciplined experimentation, and intellectual humility remain among the most important tools available to engineers. Technologies change, algorithms evolve, and new forms of automation emerge, but the principles of careful observation, transparent reasoning, and honest acknowledgment of uncertainty endure.
Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης Γρηγόριος, Αγαθαγγελιδης Γρηγοριος, Grigorios Agathangelidis.
Contents
Table of Contents
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.