knitr::opts_chunk$set(collapse = TRUE, prompt=TRUE)
library(magrittr)

Overview

Optmatch finds optimal matches by translating them to min-cost flow problems (Rosenbaum, 1991, JRSS-B; Hansen and Klopfer, 2006, JCGS), relying on a min-cost flow solver that works by dual ascent. Through 2018 (version 0.9*), no attempt was made to store the dual problem solution found by this solver; accordingly, it was not possible to use that solution as a starting value for related matching problems. This document lays out a roadmap for "daylighting" the min-cost flow material, i.e. making it accessible to the R user, for warm starts and supplementary calculations.

Proximate goals

  1. When solver saw a discretized version of the distance, check whether solution is optimal for matching problem w/ double precision distance (by checking whether primal solution and back-transformed dual solution stand in CS relation to one another). (Cf. issue 160.)
  2. Warm starts for MCF problems deriving from same double-precision distance but w/ a different discretization. (Cf. issue 76.)
  3. Use dual solution to one problem as warm start for another problem with same arcs, arc costs as in original problem but adding new arcs (between existing nodes).
  4. Use dual solution to one problem as warm start for another problem with same arcs and arc costs, but adding new "downstream" nodes and new arcs connecting them to existing "upstream" nodes.

Maybe-later goals

Classes

Subproblems / SubProbInfo

An SubProbInfo is an S4-typed data frame bearing information about (sub)problems passed to the solver, and their translation to and from units acceptable to the solver. Columns:

Rules/conventions:

Fig. 2 of Hansen & Klopfer, 2006, JCGS

NodeInfo & subclasses

A NodeInfo is an S4-typed data frame bearing a non-null row.names attribute and columns:

Rules/conventions:

ArcInfo

An ArcInfo has 2 slots:

Rules/conventions:

Primal-dual solution pairs (MCFSolutions)

In practice, current plans call only for passing dual solutions (arrays of node prices), not also primal solutions (flow vectors), back to the solver. But in principle the relax4f solver could accommodate dual-primal pairs as start values, at the cost of rejiggering our interactions; see comments to issue 162. Also assessing CS requires the combo of a primal and dual solution. So we'll save both of them, as an S4 object.

Slots for class MCFSolutions:

Rules/conventions:

ifelse(with(object@subproblems, flipped[match(object@nodes$groups,groups)]),
       !object@nodes$upstream_not_down,
       object@nodes$upstream_not_down)

Subtypes for specific matching problems

Different kinds of matching problem have different bookkeeping nodes, implicit arc capacity constraints etc. Encode all this by declaring appropriate subclasses of MCFSolutions().

FullmatchMCFSolutions

A type extending MCFSolutions(), w/ characteristics:

Return value of fullmatch / pairmatch (*ptmatch)

Immediate plan

Return an object bearing S3 class "optmatch", as we did before these changes. Embed an MCFSolutions into it as an attribute.

Final solution

Return object of a new S4 class, Optmatch, inheriting from factor as well as from MCFSolutions.

Methods & Functions



markmfredrickson/optmatch documentation built on Nov. 24, 2023, 3:38 p.m.