| 246 | typename rhs_type |
| 247 | > |
| 248 | bool is_assignment_problem ( |
| 249 | const std::vector<std::pair<std::vector<lhs_type>, std::vector<rhs_type> > >& samples, |
| 250 | const std::vector<std::vector<long> >& labels |
| 251 | ) |
| 252 | { |
| 253 | std::vector<bool> seen_label; |
| 254 | |
| 255 | if (is_learning_problem(samples, labels)) |
| 256 | { |
| 257 | for (unsigned long i = 0; i < samples.size(); ++i) |
| 258 | { |
| 259 | if (samples[i].first.size() != labels[i].size()) |
| 260 | return false; |
| 261 | |
| 262 | seen_label.assign(samples[i].second.size(), false); |
| 263 | |
| 264 | for (unsigned long j = 0; j < labels[i].size(); ++j) |
| 265 | { |
| 266 | if (!(-1 <= labels[i][j] && labels[i][j] < (long)samples[i].second.size())) |
| 267 | return false; |
| 268 | |
| 269 | if (labels[i][j] != -1) |
| 270 | { |
| 271 | // check label uniqueness |
| 272 | if (seen_label[labels[i][j]]) |
| 273 | return false; |
| 274 | |
| 275 | seen_label[labels[i][j]] = true; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | return true; |
| 280 | } |
| 281 | |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | // ---------------------------------------------------------------------------------------- |
| 286 | |