void filterDataSet(VS &data, const int scenario, const bool includeClass) { VI indices; if (scenario == 2) { VI sc3 = {11, 13, 19, 20, 21, 22, 23, 24, 25, 26}; indices.insert(indices.begin(), sc3.begin(), sc3.end()); } if (scenario >= 1) { VI sc2 = {2, 3, 4, 5, 6, 7, 8, 9, 10}; indices.insert(indices.begin(), sc2.begin(), sc2.end()); } VI sc1 = {1, 12, 14, 15, 16, 17, 18}; indices.insert(indices.begin(), sc1.begin(), sc1.end()); for (int i = 0; i < data.size(); i++) { string line = data[i]; VS values = splt(line); string newLine; for (int j = 0; j < indices.size(); j++) { newLine.append(values[indices[j] - 1]); if (j < indices.size() - 1) { newLine.append(","); } } if (includeClass) { newLine.append(","); newLine.append(values[iqCol]); } // store new data data[i] = newLine; } }
void solve(VI ans) { sort(ans.begin(),ans.end()); int sz=ans.size(); if(sz>=fs) { return; } if(ct==n) { fs=sz; finn=ans; return; } int i,j,k,pos,ti; VI tv; VI::iterator it; for(i=0;i<n;++i) { if(fl[i]) { continue; } ++ct; for(j=0;j<sz;++j) { fl[i]=0; pos=101; ti=tarr[i]+ans[j]; for(k=j+1;k<sz;++k) { if(ans[k]==ti) { fl[i]=1; break; } else if(ans[k]>ti) { pos=k; break; } } if(fl[i]) { tv=ans; solve(tv); } else { tv=ans; fl[i]=1; if(pos<101) { it=lower_bound(tv.begin(),tv.end(),ti); tv.insert(it,ti); solve(tv); } else { tv.PB(ti); solve(tv); } } fl[i]=0; } --ct; } for(i=0;i<n;++i) { if(fl[i]) { continue; } ++ct; for(j=1;j<sz;++j) { fl[i]=0; pos=101; ti=ans[j]-tarr[i]; if(ti<0) { continue; } for(k=0;k<j;++k) { if(ans[k]==ti) { fl[i]=1; break; } else if(ans[k]>ti) { pos=k; break; } } if(fl[i]) { tv=ans; solve(tv); } else { tv=ans; fl[i]=1; if(pos<101) { it=lower_bound(tv.begin(),tv.end(),ti); tv.insert(it,ti); solve(tv); } else { tv.PB(ti); solve(tv); } } fl[i]=0; } --ct; } }