Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solveQP failes, but is correct in original albertosantini/node-quadprog #78

Open
tornordqvist opened this issue Mar 16, 2017 · 0 comments

Comments

@tornordqvist
Copy link

I have a test case, where numeric.solveQP failes, but it is correct in the the original Alberto Santini's quadprog code. The D-matrix has ok eigen-values. But I guess it has something to do with the constraints A and b0. Maybe base0to1 or base1to0 is used incorrectly.

=====================================================
var numeric = require('numeric');
var qp = require("quadprog");

var mu = [0.14097628928335038, 0.09964705882352941, 0.043873181810709344, 0.02623529411764705, 0.10058823529411764];
var cov = [[0.05970495870153234, 0.01296574669996471, 0.034799597965346166, -0.001511744225804883, 0.005894763962355329], [0.01296574669996471, 0.02144394140625, 0.016214107224563266, 0.0071884048109013875, 0.0022726480300834452], [0.034799597965346166, 0.016214107224563266, 0.06446081115219693, 0.000544637705909025, 0.002215406265157739], [-0.001511744225804883, 0.0071884048109013875, 0.000544637705909025, 0.007711035156249998, 0.00013323325202656668], [0.005894763962355329, 0.0022726480300834452, 0.002215406265157739, 0.00013323325202656668, 0.0018651601562500004]];
var A = [[1, -1, 1, 0, 0, 0, 0, 0.14097628928335038, -0.14097628928335038], [1, -1, 0, 1, 0, 0, 0, 0.09964705882352941, -0.09964705882352941], [1, -1, 0, 0, 1, 0, 0, 0.043873181810709344, -0.043873181810709344], [1, -1, 0, 0, 0, 1, 0, 0.02623529411764705, -0.02623529411764705], [1, -1, 0, 0, 0, 0, 1, 0.10058823529411764, -0.10058823529411764]];
var d = [0, 0, 0, 0, 0];
var b0 = [1, -1, 0, 0, 0, 0, 0, 0.10819314780743514, -0.10819314780743514];

var res_wrong = numeric.solveQP(cov, d, A, b0);
var res_correct = qp.solveQP(base0to1(cov), base0to1(d), base0to1(A), base0to1(b0));

function base0to1(A) {
if (typeof A !== "object") { return A; }
var ret = [], i, n = A.length;
for (i = 0; i < n; i++) ret[i + 1] = base0to1(A[i]);
return ret;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant