function [ optiX, optiLambda, total_iterations ] = solve_problem_primal_dual( x, lambda, c, A, b, mu )
%SOLVE_PROBLEM_PRIMAL_DUAL Summary of this function goes here
%   Detailed explanation goes here

% init
tol = 1e-3;
primal_size = size(x, 1);
m = size(lambda,1);
total_iterations = 0;

for i = 1:1000
    fprintf('start iteration %d.\n', i);
    eta = evaluate_surrogate_duality_gap(x, lambda, A, b);
    t = mu * m / eta;
    
    if (eta <= tol)
        break;
    end
    
    r=evaluate_residual(x, lambda, c, A, b, t);
    J=evaluate_jacobian_of_residual(x, lambda, c, A, b, t);
    direction = -J\r;
    
    step_size = line_search_primal_dual(x, lambda, direction, c, A, b, t);
    x = x + step_size*direction(1:primal_size);
    lambda = lambda + step_size*direction(primal_size+1:end);
    total_iterations = total_iterations + 1;
end

optiX = x;
optiLambda = lambda;

end

