Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R'赋值;s ompr或其他优化函数_R_Optimization_Modeling - Fatal编程技术网

R'赋值;s ompr或其他优化函数

R'赋值;s ompr或其他优化函数,r,optimization,modeling,R,Optimization,Modeling,想知道这是否可以通过omprR包(或任何其他优化包)解决 我有n处理和m细胞系,对于每个处理:细胞系对,我进行了一个实验,读数是细胞系对处理的敏感性 现在我需要进行一个验证性实验,在这里我需要选择I治疗,其中我需要为每个治疗选择j敏感和j非敏感细胞系(在我的情况下I=40和j=4)。在这个验证性实验中,我在同一个平板上运行治疗和细胞系,所以我的目标是最小化细胞系的总数 我想知道这是否可以转化为Rompr可以解决的术语?如果我正确解释了您的问题,我使用ompr对其进行建模。如果我理解正确的话,你会

想知道这是否可以通过
ompr
R
(或任何其他优化
)解决

我有
n
处理和
m
细胞系,对于每个处理:细胞系对,我进行了一个实验,读数是细胞系对处理的敏感性

现在我需要进行一个验证性实验,在这里我需要选择
I
治疗,其中我需要为每个治疗选择
j
敏感和
j
非敏感细胞系(在我的情况下
I
=40和
j
=4)。在这个验证性实验中,我在同一个平板上运行治疗和细胞系,所以我的目标是最小化细胞系的总数


我想知道这是否可以转化为R
ompr
可以解决的术语?

如果我正确解释了您的问题,我使用
ompr
对其进行建模。如果我理解正确的话,你会希望将治疗的子集与细胞系相匹配。每次治疗应与两个敏感细胞系和两个非敏感细胞系相匹配。我进一步假设,细胞系可以在治疗中共享,否则就没有必要最小化细胞系的数量

首先,我们需要为模型创建输入数据。我使用你在问题中选择的符号

# For testing I chose small numbers.
# Number of treatments
n <- 10
# Number of cell lines
m <- 10
# Number of treatments for confirmatory experiment
i <- 4

# simulation of treatment results
# a data.frame with a sensitivity result for each treatment/cell_line combination.
# the result is either TRUE (sensitive) or FALSE (not sensitive)
treatment_results <- expand.grid(treatment = 1:n, cell_line = 1:m)
treatment_results$result <- runif(nrow(treatment_results)) < 0.3
给定该模型,我们可以使用GLPK进行求解。请注意,使用较大的参数,模型可能需要很长时间

# you can solve the model using GLPK for example
library(ompr.roi)
library(ROI.plugin.glpk)
result <- solve_model(model, with_ROI("glpk", verbose = TRUE))

# let's examine the solution
library(dplyr)
# this is the list of treatments selected for testing
filter(get_solution(result, y[k]), value > 0)$k

# this is the list of cell_lines selected for testing
filter(get_solution(result, z[j]), value > 0)$j

# the actual matching of treatment and cell_line is in the x variable
get_solution(result, x[k, j]) %>%
  filter(value > 0) %>%
  inner_join(treatment_results, by = c("k" = "treatment", "j" = "cell_line"))
#例如,您可以使用GLPK求解模型
图书馆(ompr.roi)
库(ROI.plugin.glpk)

结果如果我正确解释了您的问题,我使用
ompr
对其进行建模。如果我理解正确的话,你会希望将治疗的子集与细胞系相匹配。每次治疗应与两个敏感细胞系和两个非敏感细胞系相匹配。我进一步假设,细胞系可以在治疗中共享,否则就没有必要最小化细胞系的数量

首先,我们需要为模型创建输入数据。我使用你在问题中选择的符号

# For testing I chose small numbers.
# Number of treatments
n <- 10
# Number of cell lines
m <- 10
# Number of treatments for confirmatory experiment
i <- 4

# simulation of treatment results
# a data.frame with a sensitivity result for each treatment/cell_line combination.
# the result is either TRUE (sensitive) or FALSE (not sensitive)
treatment_results <- expand.grid(treatment = 1:n, cell_line = 1:m)
treatment_results$result <- runif(nrow(treatment_results)) < 0.3
给定该模型,我们可以使用GLPK进行求解。请注意,使用较大的参数,模型可能需要很长时间

# you can solve the model using GLPK for example
library(ompr.roi)
library(ROI.plugin.glpk)
result <- solve_model(model, with_ROI("glpk", verbose = TRUE))

# let's examine the solution
library(dplyr)
# this is the list of treatments selected for testing
filter(get_solution(result, y[k]), value > 0)$k

# this is the list of cell_lines selected for testing
filter(get_solution(result, z[j]), value > 0)$j

# the actual matching of treatment and cell_line is in the x variable
get_solution(result, x[k, j]) %>%
  filter(value > 0) %>%
  inner_join(treatment_results, by = c("k" = "treatment", "j" = "cell_line"))
#例如,您可以使用GLPK求解模型
图书馆(ompr.roi)
库(ROI.plugin.glpk)
结果