mathematical-optimization

Dependency Algorithm - find a minimum set of packages to install

好久不见. 提交于 2019-12-31 10:41:52
问题 I'm working on an algorithm which goal is to find a minimum set of packages to install package "X". I'll explain better with an example: X depends on A and (E or C) A depends on E and (H or Y) E depends on B and (Z or Y) C depends on (A or K) H depends on nothing Y depends on nothing Z depends on nothing K depends on nothing The solution is to install: A E B Y. Here is an image to describe the example: Is there an algorithm to solve the problem without using a brute-force approach? I've

Dependency Algorithm - find a minimum set of packages to install

浪子不回头ぞ 提交于 2019-12-31 10:41:42
问题 I'm working on an algorithm which goal is to find a minimum set of packages to install package "X". I'll explain better with an example: X depends on A and (E or C) A depends on E and (H or Y) E depends on B and (Z or Y) C depends on (A or K) H depends on nothing Y depends on nothing Z depends on nothing K depends on nothing The solution is to install: A E B Y. Here is an image to describe the example: Is there an algorithm to solve the problem without using a brute-force approach? I've

R linear model with constraints

*爱你&永不变心* 提交于 2019-12-30 10:37:29
问题 I want to fit a linear model y ~ a_1 * x_1 + ... + a_n * x_n with parameter constraints a_1,...,a_n >=0 and a_1 + ... + a_n <= 1 in R. Is there an elegant and fast way to do that and without using solve.QP of the quadprog package. It would be wonderful if a short but detailed use case would be outlined for a proposed solution. 回答1: You can use constrOptim with cost function least square and contraints defined such that ui %*% a >= ci . Suppose n=3 . You want constraints such as: a1 >= 0 a2 >=

Implementation of Matlab's fmincon function in C++

拜拜、爱过 提交于 2019-12-30 07:18:46
问题 We're currently using Matlab's fmincon function to do non-linear optimization for a project I'm working on. We need to port that part of the project to C++ in order to integrate it with other parts of the project. Is there a good way to compile the fmincon function into a library that we can use in C++? Or, is there already a library available somewhere that implements fmincon ? If neither of the above are an option, what optimization libraries are available that would be fairly easy to

Implementation of Matlab's fmincon function in C++

点点圈 提交于 2019-12-30 07:18:09
问题 We're currently using Matlab's fmincon function to do non-linear optimization for a project I'm working on. We need to port that part of the project to C++ in order to integrate it with other parts of the project. Is there a good way to compile the fmincon function into a library that we can use in C++? Or, is there already a library available somewhere that implements fmincon ? If neither of the above are an option, what optimization libraries are available that would be fairly easy to

Partition an array into K subarrays with minimal difference

末鹿安然 提交于 2019-12-30 07:05:31
问题 DISCLAIMER: Described problem looks like a task from a competition. I'm not participating in any of them, I'm not aware about any ongoing competitions, which might involve the problem. If there are any of them, I'll close the question to stay fair! I have a problem: given an array A of values and integer K, split A into exactly K non-overlapping contiguous subarrays in such way that difference between a subarray with minimal and a subarray maximum sums is minimal. It is allowed to rotate A by

What is an intuitive explanation of the Expectation Maximization technique? [closed]

北慕城南 提交于 2019-12-29 10:08:51
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . Expectation Maximization (EM) is a kind of probabilistic method to classify data. Please correct me if I am wrong if it is not a classifier. What is an intuitive explanation of this EM technique? What is expectation here and what is being maximized ? 回答1: Note: the code behind this

Find local maxima in grayscale image using OpenCV

亡梦爱人 提交于 2019-12-28 03:46:07
问题 Does anybody know how to find the local maxima in a grayscale IPL_DEPTH_8U image using OpenCV? HarrisCorner mentions something like that but I'm actually not interested in corners ... Thanks! 回答1: I think you want to use the MinMaxLoc(arr, mask=NULL)-> (minVal, maxVal, minLoc, maxLoc) Finds global minimum and maximum in array or subarray function on you image 回答2: A pixel is considered a local maximum if it is equal to the maximum value in a 'local' neighborhood. The function below captures

R optimize multiple parameters

非 Y 不嫁゛ 提交于 2019-12-25 17:59:10
问题 I am using R optim() function to estimate set of parameters which optimize user defined function shown below. But optim() out put is: Error in optim(pstart, llAgedepfn, method = "L-BFGS-B", upper = up, lower = lo) : L-BFGS-B needs finite values of 'fn' Please help. The complete script is shown below: dataM<-cbind(c(1.91,0.29,0.08,0.02,0.01,0.28,0.45,0.36,0.42,0.17,0.16,0.06,0.17,0.17,0.12), c(0.27,4.54,0.59,0.05,0.04,0.13,0.48,0.68,0.66,0.18,0.11,0.06,0.08,0.08,0.08), c(0.07,0.57,4.48,0.48,0

Recalculate an average value

人走茶凉 提交于 2019-12-25 14:18:18
问题 In my Java application I need to recalculate an average value based on the following data: I know current avg value - avgValue I know that avgValue is an average value for list of 12 values - count . Based on this information how to recalculate avgValue when a new value is added to this list of previous 12 values. What is the new avgValue for list of 13 values - count + 1 ? 回答1: Current Sum = avgValue * 12 New sum = current Sum + New value New average = New sum / 13 回答2: If you want to make