File: milp.R

package info (click to toggle)
rglpk 0.6-0-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 156 kB
  • ctags: 8
  • sloc: ansic: 283; sh: 52; makefile: 1
file content (23 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## MILP constructor
## borrowed from KH's relations package

## objective: numeric vector
## constraints: list [[1]] constr_mat
##                   [[2]] constr_dir,
##                   [[3]] constr_rhs),
## integers:
## maximum: logical

MILP <-
function(objective, constraints, bounds = NULL, types = NULL,
         maximum = FALSE)
{
    ## In the simples case, 'constraints' is a (not necessarily named)
    ## list with mat, dir and rhs.  Advanced solvers might allow for
    ## more advanced constraints, but let's worry about this later (and
    ## maybe also a little MILP_constraints() wrapper ...).

    structure(list(objective = slam::as.simple_triplet_matrix(objective), constraints = constraints,
                   bounds = bounds, types = types, maximum = maximum),
              class = "MILP")
}