function testalgorithm
    global call_to_oracle
    eps = 0.01;
    alg1 = @BasicAlgorithm1;
    alg2 = @BasicAlgorithm2;
    
    % test BasicAlgorithm1
    call_to_oracle = 0;
    path1 = alg1(@oracle);
    alg1_oracle_calls = call_to_oracle;
    [is_feasible1, t_length1] = CheckPathFeasibility(path1, eps);
    
    % test BasicAlgorithm2
    call_to_oracle = 0;
    path2 = alg2(@oracle);
    alg2_oracle_calls = call_to_oracle;
    [is_feasible2, t_length2] = CheckPathFeasibility(path2, eps);
    
    % print statistics for the solved problems
    fprintf('Basic Algorithm 1: Feasibility: %d oracle calls: %d, path length: %.2f \n',is_feasible1, alg1_oracle_calls,t_length1);
    fprintf('Basic Algorithm 2: Feasibility: %d oracle calls: %d, path length: %.2f \n',is_feasible2, alg2_oracle_calls,t_length2);
    
    
end


function [is_feasible, t_length] = CheckPathFeasibility(path, eps)
    n = size(path,1);
    t_length = Inf;
    % verify that the path is outside the disk
    if(0 == IsOutOfDisk(path(n,1),path(n,2)))
        is_feasible = 0;        
    else
        % verify that the path is epsilon feasible
        x0 = 0; y0=0;
        t_length = 0;
        for i=2:n
            x1 = path(i,1); y1 = path(i,2);
            tmp = sqrt(  (x0-x1)^2 + (y0-y1)^2  );
            t_length = t_length + tmp; 
            v_x = (x1-x0); v_y = (y1-y0); 
            for j=0:floor(1/eps);
                tmp_x = x0+(j*eps)*(v_x);
                tmp_y = y0+(j*eps)*(v_y);
                if(1==oracle([tmp_x,tmp_y]))
                    t_length = Inf;
                    is_feasible = 0;
                    return;
                end
            end                        
            x0 = x1; y0=y1;
        end
        is_feasible = 1;
    end
end

function res = IsOutOfDisk(x,y)
    res = (x)^2 + (y)^2 >= 1;
end