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

standard2canonical.m wrong implementation #1

Open
mh510 opened this issue Oct 11, 2018 · 0 comments
Open

standard2canonical.m wrong implementation #1

mh510 opened this issue Oct 11, 2018 · 0 comments

Comments

@mh510
Copy link

mh510 commented Oct 11, 2018

Hi, a great book first of all. I found an error in the file standard2canonical.m and the corresponding text is also misleading. On page 15 (29/639) it says: "Finally, we remove variable x1 from the objective function and the other constraints.". You forgot to insert the equation for x1 into the other equations as you did in the following example on the same page.

Here's my sloppy implementation (assuming that we just have equality constraints):

function [A, c, b] = standard2canonical0(A, c, b)
[m,~] = size(A);
for i = 1:m
    s = find(A(i,:) ~= 0);
    s = s(1);
    
    as = A(i,s);
    cs = c(s);
    As = A(i,:);
    bs = b(i);
    
    c = c-cs/as*As';
    
    for j = 1:m
        if j == i
            A(j,:) = A(j,:)/as;
            b(j) = b(j)/as;
        else
            ajs = A(j,s);
            A(j,:) = A(j,:)-ajs/as*As;
            b(j) = b(j)-ajs/as*bs;
        end
    end
    
    c(s) = [];
    A(:,s) = [];
end
end
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