Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccc101c
commit f6d48bd
Showing
15 changed files
with
682 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
Package: rspa | ||
Maintainer: Mark van der Loo <mark.vanderloo@gmail.com> | ||
License: GPL-3 | ||
Title: Adapt Numerical Records To Fit (In)Equality Restrictions | ||
Title: Adapt Numerical Records to Fit (in)Equality Restrictions | ||
Type: Package | ||
LazyLoad: yes | ||
Author: Mark van der Loo | ||
Description: Based on (optionally sparse) quadratic optimization with the main | ||
algorithms implemented in C. Includes features for easy processing of many | ||
(smaller) records. The algorithm has been tested on fairly large | ||
optimization problems with up to a few million variables and several | ||
hundred thousand restrictions. | ||
Version: 0.1-6 | ||
Depends: R (>= 2.13.0), editrules | ||
Description: Based on (optionally sparse) quadratic optimization with the main algorithms implemented in C. Includes features for easy processing of many (smaller) records. The algorithm has been tested on fairly large optimization problems with up to a few million variables and several hundred thousand restrictions. | ||
Version: 0.1-7 | ||
Depends: R (>= 2.13.0) | ||
Imports: editrules | ||
URL: https://github.com/markvanderloo/rspa | ||
Date: 2013-10-21 | ||
BugReports: https://github.com/markvanderloo/rspa/issues | ||
VignetteBuilder: knitr | ||
Date: 2015-06-10 | ||
Suggests: knitr, testthat | ||
Packaged: 2014-11-26 11:05:13 UTC; mark | ||
NeedsCompilation: yes | ||
Packaged: 2015-06-10 12:27:26 UTC; mark | ||
Repository: CRAN | ||
Date/Publication: 2014-11-26 12:44:09 | ||
Date/Publication: 2015-06-10 15:10:52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
## ----echo=FALSE, results="hide",include=FALSE---------------------------- | ||
library(knitr) | ||
library(rspa) | ||
library(editrules) | ||
opts_chunk$set(size='small') | ||
|
||
## ----tidy=FALSE---------------------------------------------------------- | ||
E <- editmatrix(expression( | ||
x5 == x1 + x8, | ||
x5 == x3 + x4, | ||
x8 == x6 + x7, | ||
x4 > 0)) | ||
|
||
## ----tidy=FALSE---------------------------------------------------------- | ||
x <- c( | ||
x1=330, | ||
x2=20, | ||
x3=1000, | ||
x4=30, | ||
x5=950, | ||
x6=500, | ||
x7=200, | ||
x8=700) | ||
|
||
## ------------------------------------------------------------------------ | ||
violatedEdits(E,x,tol=1e-2) | ||
|
||
## ------------------------------------------------------------------------ | ||
E <- reduce(substValue(E,'x5',x['x5'])) | ||
|
||
## ------------------------------------------------------------------------ | ||
(y <- adjust(E, x)) | ||
|
||
## ------------------------------------------------------------------------ | ||
violatedEdits(E, y$x, tol = 1e-2) | ||
|
||
## ----echo=FALSE---------------------------------------------------------- | ||
set.seed(1976) | ||
|
||
## ----tidy=FALSE---------------------------------------------------------- | ||
F <- editmatrix(expression( | ||
x + y == z, | ||
x >= 0, | ||
y >= 0, | ||
z >=0 | ||
)) | ||
N <- 100 | ||
dat <- data.frame( | ||
x = runif(100), | ||
y = rnorm(100), | ||
z = rlnorm(100) | ||
) | ||
|
||
## ------------------------------------------------------------------------ | ||
A <- adjustRecords(F,dat) | ||
summary(A) | ||
|
||
## ------------------------------------------------------------------------ | ||
plot(A) | ||
|
||
## ------------------------------------------------------------------------ | ||
E | ||
|
||
## ----echo=TRUE,tidy=FALSE------------------------------------------------ | ||
rc <- data.frame( | ||
row = c( 1, 1, 2, 2, 3, 3, 3, 4), | ||
col = c( 1, 2, 3, 4, 2, 5, 6, 4), | ||
coef = c(-1,-1,-1,-1, 1,-1,-1,-1) | ||
) | ||
b <- c(-950, -950, 0,0) | ||
|
||
## ------------------------------------------------------------------------ | ||
e <- sparseConstraints(rc, b, neq=3, sorted=TRUE) | ||
e | ||
|
||
## ------------------------------------------------------------------------ | ||
x_sparse <- c(330, 700, 1000, 30, 500, 200) | ||
(adjust(e, x_sparse)) | ||
|
||
## ----eval=FALSE,tidy=FALSE,highlight=FALSE------------------------------- | ||
# library(LaF) | ||
# ## Loading required package: Rcpp | ||
# library(rspa) | ||
# ## Loading required package: editrules | ||
# | ||
# # read A-matrix | ||
# laf <- laf_open_fwf( | ||
# file = "prob2A.txt", | ||
# column_types = c("integer","integer","double"), | ||
# column_widths = c(10,10,4) | ||
# ) | ||
# rowcol <- laf[] | ||
# laf <- close(laf) | ||
# | ||
# # read b-vector | ||
# b <- read.csv("prob2b.txt",header=FALSE)[,1] | ||
# | ||
# # read x-vector | ||
# x <- read.csv("prob2x.txt",header=FALSE)[,1] | ||
# | ||
# e <- sparseConstraints(rowcol,b,neq=length(b)) | ||
# e | ||
# ## Sparse numerical constraints. | ||
# ## Variables : 474948 | ||
# ## Restrictions: 60675 (printing 0) | ||
# | ||
# y <- adjust(e, x) | ||
# y | ||
# ## Object of class 'adjusted' | ||
# ## Status : success (using 'sparse' method) | ||
# ## Accuracy : 0.00770226 | ||
# ## Objective : 47430.5 | ||
# ## Iterations: 552 | ||
# ## Timing (s): 5.661 | ||
# ## Solution (truncated at 10): | ||
# ## [1] 5.4028322 3.5246546 3.7979088 1.1202164 2.5304367 0.2037056 | ||
# ## [7] 97.9161357 1.5714899 4.5743395 -1.1756605 | ||
|
||
## ------------------------------------------------------------------------ | ||
e <- editmatrix(expression( x < 0, x > 1)) | ||
isFeasible(e) | ||
adjust(e,c(x=0.5)) | ||
|
Oops, something went wrong.