function [ step_size ] = line_search( x, direction, c, A, b, t )
%LINE_SEARCH Summary of this function goes here
%   Detailed explanation goes here

[energy0, error0] = evaluate_energy(x, c, A, b, t);
if (error0 == 1)
    fprintf('Error: infeasible starting point.\n');
end

step_size = 1;
flag = 0;

for i = 1:20
    x_plus_tdx = x + direction*step_size;
    [energy1, error1]  = evaluate_energy(x_plus_tdx, c, A, b, t);
    if (energy1 < energy0 && error1 == 0)
        flag = 1;
        break;
    end
    step_size = step_size / 2;
end

if flag == 0
    fprintf('Warning, line-search terminated because of ascent direction.\n');
    step_size = 0;
end

end

