Skip to content
Reproduced code practitioner

Operations research as compositions of a few higher-order functions

A zero-dependency Clojure library shows optimisation, sequential decision-making and validation are compositions of a small set of higher-order-function patterns.

Jiri Knesl · Internal reviewer: Flexiana Decision Lab · 30 July 2026
Read Limitations Reproduce Operations researchClojure & data-oriented systemsDecision under uncertainty

Operations research is usually taught as hundreds of named recipes: gradient descent, value iteration, the Hungarian method, particle filters, temporal-logic monitors. orhof, Operations Research in Higher-Order Functions, is a zero-dependency Clojure library built to demonstrate a different claim: most of these are compositions of a small set of higher-order-function patterns.

The shape of the idea

One generic descent framework, parameterised by a direction function and a step rule, yields gradient descent, conjugate gradient and Adam. The Bellman operator is expressed as a function transformer mdp → (V → V′), so value iteration, policy iteration and their variants share one core. Temporal-logic operators — always, eventually, until — become higher-order functions with continuous robustness semantics, which turns falsification into an optimisation problem.

What is in it

  • 251 public functions across 30 namespaces, zero third-party dependencies.
  • Three domains: continuous and discrete optimisation; Markov decision processes and reinforcement learning; temporal-logic validation.
  • 187 deterministic tests under a seeded RNG fixture, so every result reproduces.

It is the executable companion to the book Applied Higher Order Functions; every listing in the book runs against it, and Rainbow uses the same catalogue as its proving curriculum.

Why it matters commercially

When we model a client’s decision, we are not starting from a blank solver. The composition patterns here are the parts we assemble. So a modelling conversation becomes running, testable code in days rather than weeks. That is a claim about our delivery, tested on our own work. A client engagement is where it gets measured against a baseline.

Limitations & where this does not apply

The library reimplements known algorithms to demonstrate a structural thesis; it is not a claim of new mathematics, and it is not tuned to compete with specialised industrial solvers on large instances. Its 187 tests are deterministic under a seeded RNG, which fixes reproducibility but not real-world numerical edge cases.

Commercial relevance

The same composition patterns are the building blocks we reuse when modelling a client's decision, which shortens the path from a whiteboard objective to running code.

Cite this

Jiri Knesl (2026). Operations research as compositions of a few higher-order functions. Flexiana Research. https://flexiana.com/research/orhof-operations-research-as-higher-order-functions

Start with the decision

Have a decision this research touches?

If a result here maps onto a choice your business makes repeatedly, the next step is a short, senior conversation — not a large commitment.