mathematical-optimization

Performance of pyomo to generate a model with a huge number of constraints

限于喜欢 提交于 2020-01-13 09:38:09
问题 I am interested in the performance of Pyomo to generate an OR model with a huge number of constraints and variables (about 10e6). I am currently using GAMS to launch the optimizations but I would like to use the different python features and therefore use Pyomo to generate the model. I made some tests and apparently when I write a model, the python methods used to define the constraints are called each time the constraint is instanciated. Before going further in my implementation, I would

subset of data.frame columns to maximize “complete” observations

自作多情 提交于 2020-01-13 05:17:27
问题 I have a data frame with on the order of 20 numeric columns, each containing significant amounts of NA values. I would like to select a subset of these columns that will give me the most rows containing zero NA values. An exhaustive search would take a lot of computing time--is there a better way to get an approximation? Here is an example with a smaller data frame (completely arbitrary): set.seed(2) foo = as.data.frame(matrix(rnorm(200), nr = 20)) foo[sapply(foo, function(x) x > abs(x[1]))]

R- Optimx for exponential function with 2 parameters - cannot evaluate function at initial parameter values

狂风中的少年 提交于 2020-01-10 05:07:52
问题 I feel like I missed something very obvious but after an hour of fiddling/googling I cannot get this to work. Code: #Generate data from exponential model xdata<-seq_len(100) ydata<-2*exp(-2*(xdata+rnorm(100))) #Fit exponential model to data firstorder<-function(C0,k){ ynew<-C0*exp(-k*xdata) RMSE<-sum((ynew-ydata)^2,na.rm=TRUE) return(RMSE) } #Initial parameter values params<-c(1,1) #Optimize optimx(params,firstorder) Error in optimx.check(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, :

R- Optimx for exponential function with 2 parameters - cannot evaluate function at initial parameter values

非 Y 不嫁゛ 提交于 2020-01-10 05:07:22
问题 I feel like I missed something very obvious but after an hour of fiddling/googling I cannot get this to work. Code: #Generate data from exponential model xdata<-seq_len(100) ydata<-2*exp(-2*(xdata+rnorm(100))) #Fit exponential model to data firstorder<-function(C0,k){ ynew<-C0*exp(-k*xdata) RMSE<-sum((ynew-ydata)^2,na.rm=TRUE) return(RMSE) } #Initial parameter values params<-c(1,1) #Optimize optimx(params,firstorder) Error in optimx.check(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, :

solving a sparse non linear system of equations using scipy.optimize.root

一曲冷凌霜 提交于 2020-01-07 06:41:55
问题 I want to solve the following non-linear system of equations. Notes the dot between a_k and x represents dot product . the 0 in the first equation represents 0 vector and 0 in the second equation is scaler 0 all the matrices are sparse if that matters. Known K is an n x n (positive definite) matrix each A_k is a known (symmetric) matrix each a_k is a known n x 1 vector N is known (let's say N = 50). But I need a method where I can easily change N. Unknown (trying to solve for) x is an n x 1 a

solving a sparse non linear system of equations using scipy.optimize.root

◇◆丶佛笑我妖孽 提交于 2020-01-07 06:41:49
问题 I want to solve the following non-linear system of equations. Notes the dot between a_k and x represents dot product . the 0 in the first equation represents 0 vector and 0 in the second equation is scaler 0 all the matrices are sparse if that matters. Known K is an n x n (positive definite) matrix each A_k is a known (symmetric) matrix each a_k is a known n x 1 vector N is known (let's say N = 50). But I need a method where I can easily change N. Unknown (trying to solve for) x is an n x 1 a

Mathematical optimization in R [closed]

吃可爱长大的小学妹 提交于 2020-01-07 03:23:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I have the following data frames: Required <- data.table( Country=c("AT", "BE", "BG", "CY"),Mat1=c(0,5,0,5),Mat2=c(0,3,2,0),Mat3=c(10,2,0,12)) Supplied <- data.table( Country=c("AT", "BE", "BG", "CY"),Mat1=c(0,4,0,10),Mat2=c(20,20,20,0),Mat3=c(8,10,0,10)) > Required Country Mat1 Mat2 Mat3 1: AT 0 0

Linear optimization in Python using pulp

我怕爱的太早我们不能终老 提交于 2020-01-06 06:40:29
问题 So I have 3 datasets as follows, Cost data: Vcost Out[325]: P1 P2 P3 Vendors\Product List V1 0.204403 0.208178 0.198216 V2 0.220126 0.213755 0.198991 V3 0.204403 0.191450 0.203258 Risk data: Vrisk Out[326]: P1 P2 P3 Vendors\Product List V1 0.198598 0.210145 0.198157 V2 0.172897 0.178744 0.193548 V3 0.219626 0.200483 0.205069 Decision variables data: Vdecision Out[327]: P1 P2 P3 Vendors\Product List V1 a b c V2 f g h V3 k l m My objective is to minimize 0.71*Cost*x + 0.29*Risk*x subjected to

Speed of C++ operators/ simple math

拜拜、爱过 提交于 2020-01-06 05:00:09
问题 I'm working on a physics engine and feel it would help having a better understanding of the speed and performance effects of performing many simple or complex math operations. A large part of a physics engine is weeding out the unnecessary computations, but at what point are the computations small enough that a comparative checks aren't necessary? eg: Testing if two line segments intersect. Should there be check on if they're near each other before just going straight into the simple math, or

Creating Filter's Laplacian Matrix and Solving the Linear Equation for Image Filtering

只谈情不闲聊 提交于 2020-01-06 04:23:48
问题 I have an optimization problem to solve in order to filter an image. I created a Linear Equation of the problem which deals with Sparse Matrices. At first I will show the problem. First, the Laplacian (Adjacency) matrix of the problem: The matrix Dx / Dy is the forward difference operator -> Hence its transpose is the backward difference operator. The matrix Ax / Ay is diagonal matrix with weights which are function of the gradient of the image (Point wise, namely the value depends only on