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

Matlab vs R version incompatibilty #37

Closed
ahsen1402 opened this issue Oct 23, 2018 · 1 comment
Closed

Matlab vs R version incompatibilty #37

ahsen1402 opened this issue Oct 23, 2018 · 1 comment

Comments

@ahsen1402
Copy link

I am solving the same problem in matlab and R but I get different results (the solutions are completely different for some variables not just a little here and there) although all the inputs are the .same for completeness here is the matlab code:

p=132; 
cvx_begin;
variables b(p);
minimize(norm(weight'*b, 1));
subject to;
    1<matrix*b;
    0<=b;                                   
cvx_end;

and the R code:

p=132
  b=Variable(p,name="b")
  objective <- norm1(t(weight) %*% b) 
  constrnt <-list(1 < matrix %*% b,0 <= b )
 prob <- Problem(Minimize(objective), constrnt)
results <- solve(prob)
lb_solution=results$getValue(b)

Any insights on why this might happen?

@brianborchers
Copy link

Are you sure that the optimal solution to your problem is unique? Is it possible that the MATLAB and R codes are returning different solutions that are both optimal? It's quite easy to formulate examples with infinitely many optimal solutions . Even a small variation in parallel threading, run time libraries, etc. can then result in the solvers finding different solutions that are both optimal.

@bnaras bnaras closed this as completed Apr 8, 2020
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

3 participants