function [x,f]=basicsol(A,b,c,I)
%The function creates the square matrix B that consists of the columns of A
%in the index set I, B=A_I. If B is not invertible the function ends.
%Otherwise it computes the vector x_B=inv(B)b of basic variables and
%creates the vector of the corresponding basic solution x. It also computes
%the value of the objective function f=c'x.
%Inputs : A : mxn matrix, with m<=n, rank(A)=m
%b : column vector of size m, b>=0
%c: column vector of size n
%I: Vector of size m, subset of {1, 2, ..., n} that contains the indices of
%the columns of A that form matrix B.
%
    [m,n]=size(A);
    B=A(:,I);
    if det(B)==0 xb=-1; x=-1; f=-10^12; return; 
    else xb=B\b;
        x=zeros(n,1);
        x(I)=xb;
        f=c'*x;
    end;