Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ompr v1 #349

Merged
merged 10 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v1

- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: rcmdcheck

- uses: r-lib/actions/check-r-package@v1
84 changes: 0 additions & 84 deletions .github/workflows/check-standard.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# History files
.Rhistory
.Rapp.history
.DS_Store

# Session Data files
.RData
Expand Down
32 changes: 23 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,35 @@ Description: Model mixed integer linear programs in an algebraic way directly in
documentation and examples.
License: GPL-3
LazyData: TRUE
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Encoding: UTF-8
URL: https://github.com/dirkschumacher/ompr
BugReports: https://github.com/dirkschumacher/ompr/issues
Depends: R (>= 3.2.0)
Imports:
lazyeval,
progress,
rlang (>= 0.2.0),
methods,
data.table,
Rcpp (>= 0.12.12),
Matrix
lazyeval,
progress,
rlang (>= 0.2.0),
listcomp (>= 0.3.0.9000),
methods,
data.table,
Matrix,
fastmap
Suggests:
magrittr,
testthat
Remotes:
dirkschumacher/listcomp
ByteCompile: Yes
LinkingTo: Rcpp
Collate:
'abstract-model-impl.R'
'helper.R'
'linear-optimization-model-linear-functions.R'
'linear-optimization-model-impl.R'
'linear-optimization-model-linear-constraints.R'
'model-api.R'
'milp-impl.R'
'milp-linearopt-variables.R'
'ompr-package.R'
'solution-api.R'
'solution-impl.R'
54 changes: 38 additions & 16 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
# Generated by roxygen2: do not edit by hand

S3method(add_constraint,abstract_model)
S3method(add_constraint,linear_optimization_model)
S3method(add_constraint_,linear_optimization_model)
S3method(add_constraint_,milp_model)
S3method(add_constraint_,optimization_model)
S3method(add_variable,abstract_model)
S3method(add_variable,linear_optimization_model)
S3method(add_variable_,linear_optimization_model)
S3method(add_variable_,milp_model)
S3method(add_variable_,optimization_model)
S3method(extract_constraints,linear_optimization_model)
S3method(extract_constraints,milp_model)
S3method(extract_constraints,optimization_model)
S3method(get_column_duals,solution)
S3method(get_row_duals,solution)
S3method(get_solution_,solution)
S3method(nconstraints,linear_optimization_model)
S3method(nconstraints,milp_model)
S3method(nconstraints,optimization_model)
S3method(nvars,linear_optimization_model)
S3method(nvars,milp_model)
S3method(nvars,optimization_model)
S3method(objective_function,linear_optimization_model)
S3method(objective_function,milp_model)
S3method(objective_function,optimization_model)
S3method(objective_value,solution)
S3method(print,linear_optimization_model)
S3method(print,milp_model)
S3method(print,optimization_model)
S3method(print,solution)
S3method(set_bounds,abstract_model)
S3method(set_bounds,linear_optimization_model)
S3method(set_bounds_,linear_optimization_model)
S3method(set_bounds_,milp_model)
S3method(set_bounds_,optimization_model)
S3method(set_objective,abstract_model)
S3method(set_objective,linear_optimization_model)
S3method(set_objective_,linear_optimization_model)
S3method(set_objective_,milp_model)
S3method(set_objective_,optimization_model)
S3method(solve_model,milp_model)
S3method(solve_model,optimization_model)
S3method(solve_model,abstract_model)
S3method(solver_status,solution)
S3method(variable_bounds,linear_optimization_model)
S3method(variable_bounds,milp_model)
S3method(variable_bounds,optimization_model)
S3method(variable_keys,linear_optimization_model)
S3method(variable_keys,milp_model)
S3method(variable_keys,optimization_model)
S3method(variable_types,linear_optimization_model)
S3method(variable_types,milp_model)
S3method(variable_types,optimization_model)
export(MILPModel)
export(MIPModel)
export(add_constraint)
Expand All @@ -57,11 +64,26 @@ export(set_objective_)
export(solve_model)
export(solver_status)
export(sum_expr)
export(sum_over)
export(variable_bounds)
export(variable_keys)
export(variable_types)
import(data.table)
importFrom(Rcpp,sourceCpp)
importFrom(Matrix,sparseMatrix)
importFrom(Matrix,sparseVector)
importFrom(fastmap,fastmap)
importFrom(lazyeval,as.lazy)
importFrom(lazyeval,as.lazy_dots)
importFrom(lazyeval,lazy_dots)
importFrom(listcomp,gen_list)
importFrom(methods,new)
importFrom(rlang,abort)
importFrom(rlang,caller_env)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
importFrom(rlang,eval_bare)
importFrom(rlang,get_expr)
importFrom(rlang,new_environment)
importFrom(rlang,new_quosure)
importFrom(rlang,syms)
importFrom(stats,setNames)
useDynLib(ompr)
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# ompr (development version)

## General changes

* Rewrote the `MIPModel`. It should now be faster, more maintainable,
more stable and it has fewer bugs.
* `sum_over` shall now be used in favor of `sum_expr` in the `MIPModel`

## Bugfixes

* Fixed a bug where using the index "e" in `sum_expr` failed (#327)
* Fixed a bug where coefficients that came after the variable in the
expression would sometimes not be correctly parsed (#265)
* Fixed a bug where `add_variable` failed if indexes were in the wrong order
(#266)

## Deprecations

All listed functions will be removed at some point the future.

* `sum_expr` shall not be used anymore. Please use `sum_over` instead.
* `MIPLModel` will likely be removed from the package, as the vectorized
approach did lead to some problems. Please use `MIPModel` instead.
* `add_variable_`, `add_constraint_`, `set_objective_`, `set_bounds` and
`get_solution_` are not needed anymore with the new `MIPModel` as it is
powered by `rlang`.

# ompr 0.8.1

## General changes
Expand Down
11 changes: 0 additions & 11 deletions R/RcppExports.R

This file was deleted.

63 changes: 63 additions & 0 deletions R/abstract-model-impl.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#' @export
add_variable.abstract_model <- function(.model, .variable, ...,
type = "continuous",
lb = -Inf, ub = Inf) {
add_variable_(
.model = .model,
.variable = lazyeval::as.lazy(
substitute(.variable), parent.frame()
),
type = type,
lb = lb,
ub = ub,
.dots = lazyeval::lazy_dots(...)
)
}

#' @export
set_objective.abstract_model <- function(model, expression,
sense = c("max", "min")) {
set_objective_(model,
expression = lazyeval::as.lazy(
substitute(expression),
parent.frame()
),
sense = sense
)
}

#' @export
add_constraint.abstract_model <- function(.model, .constraint_expr, ...,
.show_progress_bar = TRUE) {
add_constraint_(.model, lazyeval::as.lazy(
substitute(.constraint_expr),
parent.frame()
),
.dots = lazyeval::lazy_dots(...),
.show_progress_bar = .show_progress_bar
)
}

#' @export
set_bounds.abstract_model <- function(.model, .variable, ...,
lb = NULL, ub = NULL) {
set_bounds_(
.model = .model,
.variable = lazyeval::as.lazy(
substitute(.variable), parent.frame()
),
lb = lb,
ub = ub,
.dots = lazyeval::lazy_dots(...)
)
}

#' @export
solve_model.abstract_model <- function(model, solver) {
if (!is.function(solver)) {
stop(paste0("Solver is not a function Model -> Solution.\n",
"Take a look at the examples on the website on how to call",
" solve_model."))
}
solver(model)
}
13 changes: 0 additions & 13 deletions R/class-constraint.R

This file was deleted.

Loading