File: Misc.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 (34 lines) | stat: -rw-r--r-- 1,343 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
24
25
26
27
28
29
30
31
32
33
34
## Miscellaneous functions used in this package

## Get the right representation of integer vector.
## This function takes an index vector and returns a vector of logicals
## with length 'n'.

#glp_integers <-
#function(x, n)
#{
#  if(!all(x <= n))
#stop("Indices must not exceed the number of objective coefficients.")
#  out <- logical(n)
#  out[x] <- TRUE
#  out
#}

print.MP_data_from_file <- function(x, ...){
  if(!inherits(x, "MP_data_from_file"))
     stop("'x' must be of class 'MP_data_from_file'")
  if(attr(x, "n_integer_vars") > 0L){
    writeLines(paste("A mixed integer linear program with",
                     attr(x, "n_objective_vars"), "objective variables,"))
    writeLines(paste(attr(x, "n_integer_vars"), "are integer and",
                     attr(x, "n_binary_vars"), "of which are binary variables."))
    writeLines(paste("This problem has", attr(x, "n_constraints"),
                     "constraints with", attr(x, "n_nonzeros"),
                     "non-zero values in the constraint matrix."))
  } else{
    writeLines(paste("A linear program with", attr(x, "n_objective_vars"), "objective variables."))
    writeLines(paste("This problem has", attr(x, "n_constraints"),
                     "constraints with", attr(x, "n_nonzeros"),
                     "non-zero values in the constraint matrix."))
  }
}