楼主: oliyiyi
1384 2

Mathematical programming in R [推广有奖]

版主

泰斗

0%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
271951 个
通用积分
31269.3519
学术水平
1435 点
热心指数
1554 点
信用等级
1345 点
经验
383775 点
帖子
9598
精华
66
在线时间
5468 小时
注册时间
2007-5-21
最后登录
2024-4-18

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

OMPR (Optimization Modelling Package) is a DSL to model and solve Mixed Integer Linear Programs. It is inspired by the excellent Jump project in Julia.

Here are some problems you could solve with this package:

  • What is the cost minimal way to visit a set of clients and return home afterwards?
  • What is the optimal conference time table subject to certain constraints (e.g. availability of a projector)?
  • Sudokus

The Wikipedia article gives a good starting point if you would like to learn more about the topic.

This is a beta version. Currently working towards a first stable version for CRAN. At the moment not recommended for production systems / important analyses. Although most obvious bugs should be gone. Happy to get bug reports or feedback.

Supported problem classesObjective types
  • Linear

Constraint types
  • Linear

Variable types
  • Continuous
  • Integer-valued


Install

To install the current development version use devtools:

devtools::install_github("dirkschumacher/ompr")devtools::install_github("dirkschumacher/ompr.roi")

Available solver bindings[td]

Package

Description

Build Linux

Build Windows

Test coverage

ompr.roiBindings to ROI (GLPK, Symphony, CPLEX etc.)

A simple example:
  1. library(dplyr)library(ROI)library(ROI.plugin.glpk)library(ompr)library(ompr.roi)result <- MIPModel() %>%  add_variable(x, type = "integer") %>%  add_variable(y, type = "continuous", lb = 0) %>%  set_bounds(x, lb = 0) %>%  set_objective(x + y, "max") %>%  add_constraint(x + y <= 11.25) %>%  solve_model(with_ROI(solver = "glpk"))get_solution(result, x)get_solution(result, y)
复制代码



API

These functions currently form the public API. More detailed docs can be found in the package function docs or on the website

DSL
Solver

Solvers are in different packages. ompr.ROI uses the ROI package which offers support for all kinds of solvers.

  • with_ROI(solver = "glpk") solve the model with GLPK. Install ROI.plugin.glpk
  • with_ROI(solver = "symphony") solve the model with Symphony. Install ROI.plugin.symphony
  • with_ROI(solver = "cplex") solve the model with CPLEX. Install ROI.plugin.cplex
  • … See the ROI package for more plugins.


Further Examples

Please take a look at the docs for bigger examples.

Knapsacklibrary(dplyr)library(ROI)library(ROI.plugin.glpk)library(ompr)library(ompr.roi)max_capacity <- 5n <- 10weights <- runif(n, max = max_capacity)MIPModel() %>%  add_variable(x, i = 1:n, type = "binary") %>%  set_objective(sum_expr(weights * x, i = 1:n), "max") %>%  add_constraint(sum_expr(weights * x, i = 1:n) <= max_capacity) %>%  solve_model(with_ROI(solver = "glpk")) %>%   get_solution(x) %>%   filter(value > 0)

Bin Packing

An example of a more difficult model solved by symphony.

library(dplyr)library(ROI)library(ROI.plugin.symphony)library(ompr)library(ompr.roi)max_bins <- 10bin_size <- 3n <- 10weights <- runif(n, max = bin_size)MIPModel() %>%  add_variable(y, i = 1:max_bins, type = "binary") %>%  add_variable(x[i, j], i = 1:max_bins, j = 1:n, type = "binary") %>%  set_objective(sum_expr(y, i = 1:max_bins), "min") %>%  add_constraint(sum_expr(weights[j] * x[i, j], j = 1:n) <= y * bin_size, i = 1:max_bins) %>%  add_constraint(sum_expr(x[i, j], i = 1:max_bins) == 1, j = 1:n) %>%  solve_model(with_ROI(solver = "symphony", verbosity = 1)) %>%   get_solution(x[i, j]) %>%  filter(value > 0) %>%  arrange(i)


License

Currently GPL.


Contributing

As long as the package is under initial development please post an issue first before sending a PR.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Mathematical Programming mathematica Mathematic Thematic projector problems starting article package

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html
沙发
水调歌头 在职认证  发表于 2016-12-31 14:14:59 |只看作者 |坛友微信交流群

使用道具

藤椅
花茶物语 发表于 2017-1-5 15:30:44 |只看作者 |坛友微信交流群
thanks for sharing

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-20 11:14