the warning is:
Code:
aSol -> add_column(GetMax(k,instance->n_cols)); warning: passing 'double' for converting 1 of void Solution::add_column(int)'
The code of the solution is
Code:
void Solution::add_column(int i) {
selected_columns.push_back(i);
obj_value = obj_value + (instance->cost)[i];
for (int j = 0; j < (instance->covers)[i].size(); j++) {
int aRow = (instance->covers)[i][j];
if (!is_covered[aRow]) {
n_covered++;
is_covered[aRow] = true;
is_added[i] = true;
}
}
}
For the second question i did that: as u see i added the map is_added when we add a column.I also inculded it to the header file as
Code:
map<int,bool> is_added;
A little change.I didn't want to do, cause these are ready given.Maybe things get worse
And then into the main programme as:
Code:
Solution* aSol = new Solution(instance);
double k[5000];
while (!aSol -> is_complete()) {
for (int i = 0; i < instance -> n_cols ; i++) {
if (!aSol -> is_added[i]){
k[i] = (instance->covers[i].size())/(instance-> cost[i]);
}
}
aSol -> add_column(GetMax(k,instance->n_cols));
}
random_shuffle (aSol -> selected_columns.begin(), aSol -> selected_columns.end() );
How do you see that?
what do u mean i changed the return value? the return value represents the corresponding index of the biggest element(column in this case) of the set with the columns we add