econirl.LinearCost

class econirl.LinearCost[source]

Bases: Utility

Linear cost utility for the Rust bus replacement model.

Implements the utility specification from Rust (1987):

u(s, a; theta_c, RC) = -theta_c * s * (1-a) - RC * a

Where: - s is the mileage state - a is the action (0=don’t replace, 1=replace) - theta_c is the per-period operating cost coefficient - RC is the replacement cost

When a=0 (don’t replace): u = -theta_c * s (operating cost increases with mileage) When a=1 (replace): u = -RC (pay replacement cost, mileage resets)

property n_params: int

theta_c and RC.

Type:

Two parameters

property param_names: list[str]

theta_c (operating cost) and RC (replacement cost).

Type:

Parameter names

property param_bounds: tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]]

Parameter bounds enforcing non-negativity for theta_c and RC.

property param_init: ndarray[tuple[Any, ...], dtype[floating]]

Reasonable initial values for optimization.

matrix(n_states, params, n_actions=2)

Compute utility matrix for all state-action pairs.

Parameters:
  • n_states (int) – Number of states (states are 0, 1, …, n_states-1).

  • params (ndarray[tuple[Any, ...], dtype[floating]]) – Parameter vector of shape (n_params,).

  • n_actions (int) – Number of actions (default 2 for binary choice).

Returns:

Utility matrix of shape (n_states, n_actions) where result[s, a] = u(s, a; params).

Return type:

ndarray[tuple[Any, …], dtype[floating]]