solve_interval_partition_R {RcppDynProg}R Documentation

solve_interval_partition (R version)

Description

Solve a for a minimal cost partition of the integers [1,...,nrow(x)] problem where for j>=i x(i,j). is the cost of choosing the partition element [i,...,j]. Returned solution is an ordered vector v of length k where: v[1]==1, v[k]==nrow(x)+1, and the partition is of the form [v[i], v[i+1]) (intervals open on the right).

Usage

solve_interval_partition_R(x, kmax)

Arguments

x

NumericMatix, for j>=i x(i,j) is the cost of partition element [i,...,j] (inclusive).

kmax

int, maximum number of steps in solution.

Value

dynamic program solution.

Examples


x <- matrix(c(1,1,5,1,1,0,5,0,1), nrow=3)
k <- 3
solve_interval_partition_R(x, k)
solve_interval_partition(x, k)


[Package RcppDynProg version 0.2.1 Index]