% define number of items
NbItem = 40;

% define average_value
min_value = 100;

% define max_value_deviation
diff_value = 1;

% define average_weight (or dimension)
min_weight = 100;

% define max_weight_deviation (or dimension)
diff_weight = 1;

% define capacity
capacity = 1000;

% import int+ NbItem;              // Number of dimensions of the problem
% import float value[Item];        // value of item
% import float attribute[Item];    // attribute of item
% import float capacity;

% open dat file to write ----------------------------------------------------------------------

fid = fopen('knapsack.dat','w');

fprintf(fid,'NbItem = %d;\n',NbItem);

fprintf(fid,'\nvalue = [');
for I = 1:NbItem-1,
    fprintf(fid,' %f,',min_value + rand(1) * diff_value);
end
I = NbItem;
fprintf(fid,' %f];\n',min_value + rand(1) * diff_value);

fprintf(fid,'\nattribute = [');
for I = 1:NbItem-1,
    fprintf(fid,' %f,',min_weight + rand(1) * diff_weight);
end
I = NbItem;
fprintf(fid,' %f];\n',min_weight + rand(1) * diff_weight);

fprintf(fid,'\ncapacity = %d;\n',capacity);
fclose(fid);
