File: equality_test.Rout.save

package info (click to toggle)
r-cran-linprog 0.9-4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 204 kB
  • sloc: sh: 13; makefile: 2
file content (142 lines) | stat: -rw-r--r-- 3,595 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library( "linprog" )
Loading required package: lpSolve
> 
> # min x1 + x2, s.t. x1 + 0.5 * x2 = 2
> cvec <- c( 1, 1 )
> Amat <- matrix( c( 1, 0.5 ), nrow = 1 )
> bvec <- 2
> a1 <- solveLP( cvec, bvec, Amat, const.dir = "=" )
Warning message:
In solveLP(cvec, bvec, Amat, const.dir = "=") :
  solveLP() might return incorrect results if the model includes equality constraints and argument 'lpSolve' is 'FALSE'; please check if solveLP() returns the same results with argument 'lpSolve' equal to 'TRUE'; more information on this bug available at linprog's R-Forge site
> print( a1 )


Results of Linear Programming / Linear Optimization

Objective function (Minimum): 0 

Iterations in phase 1: 0
Iterations in phase 2: 0
Solution
  opt
1   0
2   0

Basic Variables
    opt
S 1   0

Constraints
  actual dir bvec free dual dual.reg
1      2   =    2    0    0       NA

All Variables (including slack variables)
    opt cvec min.c max.c marg marg.reg
1     0    1    99    77    1      Inf
2     0    1    99    77    1      Inf
S 1   0    0    NA    NA    0       NA

> 
> a2 <- solveLP( cvec, bvec, Amat, const.dir = "=", lpSolve = TRUE )
> print( a2 )


Results of Linear Programming / Linear Optimization
(using lpSolve)

Objective function (Minimum): 2 

Solution
  opt
1   2
2   0

Constraints
  actual dir bvec free
1      2   =    2    0

> 
> # max 27 * x1 + 9 * x2
> # s.t. x1 - x2 = 8  &  x1 + x2 <= 74
> cvec <- c( 27, 9 )
> bvec <- c( 8, 74 )
> Amat <- matrix( c( 1, 1, -1, 1 ), nrow = 2 ) 
> b1 <- solveLP( cvec, bvec, Amat, maximum = TRUE, const.dir = c( "==", "<=" ) )
Warning message:
In solveLP(cvec, bvec, Amat, maximum = TRUE, const.dir = c("==",  :
  solveLP() might return incorrect results if the model includes equality constraints and argument 'lpSolve' is 'FALSE'; please check if solveLP() returns the same results with argument 'lpSolve' equal to 'TRUE'; more information on this bug available at linprog's R-Forge site
> print( b1 )


Results of Linear Programming / Linear Optimization

Objective function (Maximum): 1998 

Iterations in phase 1: 0
Iterations in phase 2: 1
Solution
  opt
1  74
2   0

Basic Variables
    opt
1    74
S 1   0

Constraints
  actual dir bvec free dual dual.reg
1      8  ==    8    0    0       NA
2     74  <=   74    0   27       74

All Variables (including slack variables)
    opt cvec min.c max.c marg marg.reg
1    74   27     9   Inf   NA       NA
2     0    9  -Inf    27  -18       74
S 1   0    0  -Inf   Inf    0       NA
S 2   0    0  -Inf    27  -27       74

> 
> b2 <- solveLP( cvec, bvec, Amat, maximum = TRUE, const.dir = c( "==", "<=" ),
+    lpSolve = TRUE )
> print( b2 )


Results of Linear Programming / Linear Optimization
(using lpSolve)

Objective function (Maximum): 1404 

Solution
  opt
1  41
2  33

Constraints
  actual dir bvec free
1      8  ==    8    0
2     74  <=   74    0

> 
> proc.time()
   user  system elapsed 
  0.152   0.032   0.170