Skip to contents

Re-solves every weight to optimality with the atoms held fixed, the solve that fw_step(correct_weights = TRUE) runs after each step and ripr_finish(correct_weights = TRUE) runs at the end, by the weight_solver set in ripr_control() (SQP by default). Atoms of a part that coincide (to merge_atol and merge_rtol) are merged first, and atoms whose weight reaches zero are dropped. One step suffices, as any further weight_steps start at the optimum and converge immediately; cf. ct_step(), whose cheap multiplicative updates only approach the optimum.

Usage

weight_step(state, times = 1L, record_gap = FALSE, until = NULL)

Arguments

state

A ripr_state.

times

Steps to take.

record_gap

Sweep the Frank–Wolfe oracle over the produced mixture, filling gap_after and caching it for gap_below() and fw_step(). Off by default: a full oracle sweep per row.

until

Optional predicate function(state, candidate) tested before each step; see predicates.

Value

The updated ripr_state.

Details

The times parameter is accepted to be consistent with other steps, even though additional weight_steps after a converged solve does nothing.

Examples

set.seed(1)
fam <- multinomial_family(n_trials = 4L, k = 3L)
plurality <- null_model(
  fam,
  list(
    simplex_region(vertices = rbind(c(0.5, 0.5, 0), c(0, 1, 0), c(0, 0, 1))),
    simplex_region(vertices = rbind(c(0.5, 0, 0.5), c(0, 1, 0), c(0, 0, 1)))
  )
)
Q <- fam(c(0.4, 0.35, 0.25))
state <- ripr_init(Q, plurality) |>
  fw_step(times = 5L) |>
  weight_step()
support_gap_below(1e-6)(state)
#> [1] TRUE