Posts

Showing posts with the label optimization

Quadratic Programming with a large number of variables using CVXOPT

Image
Clash Royale CLAN TAG #URR8PPP Quadratic Programming with a large number of variables using CVXOPT I am new to CVXOPT. I have tried out the example quadratic program (with 2 variables) in CVXOPT documentation, and I am able to understand it. Now I need to solve a quadratic programming problem with a large number of variables (eg: 100 variables). How can I do this using CVXOPT? The problem that I want to solve is shown below. Minimize Σ [ d(t) + x(t) ]²        ; t=1, ....., 100 such that, 0 <= x(t) <= 10 Σ x(t) = 2000 Here, d(t) is known for t=(1, ...,100). d(t) x(t) for t=(1, ...,100) are the decision variables.   x(t) Cheers !!!  By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Is there a way to improve this this c++ code?

Image
Clash Royale CLAN TAG #URR8PPP Is there a way to improve this this c++ code? Hello I'm a programming newbie. In fact, this is my second code ever (after the hello world code). I did a lot of reading actually, here on stack overflow, and other websites, I also purchased "Jumping Into C++" By Alex Allain , And I put Everything I learned here In this code : Simple Calculator.cpp : #include <iostream> #include <string> using std::cout; using std::cin; int main() { cout << "Calculator..... n"; cout << "Type '3a3'to exit... n"; double a=0 ,b=0; char op = 'a'; //operator // 'a' is the exit operator, the value of the integers doesn't matter int ch = 0; //while loop checker do { cin >> a >> op >> b; if (op == '/' && b == 0) { cout << "Division By Zero, Please Retry n" ; goto retry; } switch (op) { case '+'...

Optimization (CodeWars Integers: Recreation One)

Image
Clash Royale CLAN TAG #URR8PPP Optimization (CodeWars Integers: Recreation One) I managed to find two algos for this CodeWars challenge (https://www.codewars.com/kata/integers-recreation-one/train/javascript). Unfortunately, they are not fast enough (> 12000ms). Any suggestions on how to improve my code ? v1 : const listSquared = (m, n) => { const result = ; for (let i = m; i <= n; i++) { const divisorsOfi = ; for (let j = 0; j <= i; j++) { if (i % j === 0) { divisorsOfi.push(Math.pow(j, 2)) } } let sumOfDivisorsOfi = 1; if (divisorsOfi.length > 1) { sumOfDivisorsOfi = divisorsOfi.reduce((a, b) => a + b); } if (Number.isInteger(Math.sqrt(sumOfDivisorsOfi))) { result.push([i, sumOfDivisorsOfi]); } } return result; } v2: const listSquared = (m, n) => { const result = ; for (let i = m; i <= n; i++) { let sumOfSqrtDivisorsOfi = divisors(i); if (Number.isInteger(Math.sqrt(sumOfSqrtDiv...

Nested for loop, data dependency [ OpenMP ]

Image
Clash Royale CLAN TAG #URR8PPP Nested for loop, data dependency [ OpenMP ] I have a matrix solver (BiCCG) which is being used to solve set of algebraic equations arising from a 3 dimensional computational domain. I have tried to parallelise it using OpenMP but struggling with performance issues. On inspecting the code using Intel Advisor, it is evident that almost 80% of the solution time goes in the solver out of which there is one function which accounts for 50% of the solution time. Digging even deeper it is found that 5 loops out of 6 loops are performing terribly with no automatic vectorization since they suffer from data dependencies. What I do see is that there is a dependency (for eg in loop 3 ) because there i th iteration is using i-1 iteration's values. How to change the design of the parallelisation such that it can be the most efficient with this algorithm ( rather that changing the algorithm altogether). Whether specifying #pragma omp simd safelen(1) would help. #pra...

How important is to formulate a convex optimization for a proposed algorithm?

How important is to formulate a convex optimization for a proposed algorithm? I proposed a new sparse coding algorithm which has goods results compared to the baselines, however, it has a non-convex optimization framework. I solved the problem using a general solver (e.g. Matlab), and although the solution is local optimum, it is still better than other relevant approaches. So how important is to formulate the problem in a convex setting? especially for publishing the work. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.