Crate utility_programming [] [src]

Utility-Programming: A library for composable utility programming.

This library is brought to you by the AdvancedResearch community.


Utility programming can be thought of as a form of programming with soft constraints. Instead of programming rules explicitly, various aspects of the solution is assigned a utility. An optimization algorithm then generates and modifies objects to maximize the utility.

The advantage of utility programming is that one feature can be traded with another. By adjusting the weights of utility of various features, the optimized object can be modified to fit new criteria without rewriting the algorithm.

Utility programming differs from other kinds of machine learning in the following ways:

These properties results in higher focus on the programming aspects by adjusting utilities.

From a library perspective, finding utility definitions that interact nicely with each other is the challenge of API designers.


The abstractions for utility programming consists of 3 parts:

All traits are implemented for Vec<T> where T implements the trait:

It is common to use enum instead of struct to combine variants with Vec<T>.

Modification requires undo and redo for backtracking and replication.

Utility Epistomology

Epistomology is philosophy of knowledge. Utility Epistomology means philosophy of utility knowledge.

Utility optimization consists of 3 major efficiency levels:

  1. Object generation (blind utility)
  2. Modification (target utility)
  3. Trade-off prediction (heuristics utility)

The optimized solution is a result of the 3 levels above. All the information that is used to evaluate the utility is stored in the object of interest. This means one can predict certain aspects of the optimal solution from the utility parameters, generators and modifiers.

An optimal agent operating at the 1st level is required behavior to be optimally creative. It is able to think of anything that might be possible for a given problem.

An optimal agent operating at the 2nd level is required behavior to be instrumentally rational. It is able to maximize its goal in the most efficient way.

An optimal agent operating at the 3rd level is required behavior to be zen rational. It is able to predict what the optimized solution might look like if the utility was different.

One motivation for developing tools for utility programming is to study Zen Rationality.



Modifies an object using a modifier by maximizing utility.



Implemented by objects that generates other objects.


Modifies objects in a way that can be reversed.


Implemented by objects that measure utility of an object.