matlab convex optimization code giving incorrect answer

조회 수: 9 (최근 30일)
Nikhil Muralidhar
Nikhil Muralidhar 2014년 1월 29일
편집: Nikhil Muralidhar 2014년 1월 29일
EDU>>f = fopen('myTextFile.txt','r')
#text file is of the form row1 col1 rating
# row2 col2 rating ...
EDU>>ln = textscan(f,'%f %f %f',inf,'Delimiter',{' '})
EDU>> myMatrix = sparse(vec(ln{1}),vec(ln{2}),vec(ln{3}),36473,4503);
EDU>>cvx_begin
EDU>> variable W(4503,1)
EDU>> minimize((square_pos(norm(myMatrix(:,1) - myMatrix*W))) + (4*norm(W)) + (10*norm(W,1)))
EDU>> subject to
EDU>> 0 <= W
EDU>> W(1,1)==0
EDU>> cvx_end
The optimization problem is solved successfully but all the variables of W meaning all the 4503 values (except W(1,1) which is 0 according to the constraint) are the exact same value.
Ex: 0
0.1338
0.1338
0.1338
0.1338
0.1338
0.1338
0.1338
......
......
This doesn't make sense because myMatrix is a sparse matrix of user/item rating information. This indicates that all users like all items equally which doesn't seem correct. I feel I am missing something here and I would appreciate any advice to help me figure out what is going on and how I can overcome this peculiar behavior.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by