Actual model
| 163 | }; |
| 164 | /// Actual model |
| 165 | QCP(const QCPOptions& opt0) |
| 166 | : Script(opt0), |
| 167 | opt(opt0), spec(opt.instance()), |
| 168 | e(*this, spec.size() * spec.size(), 0, spec.size()-1) { |
| 169 | // Problem size |
| 170 | int n = spec.size(); |
| 171 | // Matrix for elements |
| 172 | Matrix<IntVarArray> m(e, n); |
| 173 | |
| 174 | // Assign fields |
| 175 | for (int i=0; i<n; i++) |
| 176 | for (int j=0; j<n; j++) |
| 177 | if (spec.assigned(i,j)) |
| 178 | rel(*this, m(i,j) == spec.val(i,j)); |
| 179 | |
| 180 | // Post constraints |
| 181 | switch (opt.propagation()) { |
| 182 | case PROP_BINARY: |
| 183 | for (int i=0; i<n; i++) |
| 184 | for (int k=0; k<n; k++) |
| 185 | for (int l=k+1; l<n; l++) { |
| 186 | rel(*this, m(i,k) != m(i,l)); |
| 187 | rel(*this, m(k,i) != m(l,i)); |
| 188 | } |
| 189 | break; |
| 190 | case PROP_DISTINCT: |
| 191 | for (int i=0; i<n; i++) { |
| 192 | distinct(*this, m.row(i), opt.ipl()); |
| 193 | distinct(*this, m.col(i), opt.ipl()); |
| 194 | } |
| 195 | break; |
| 196 | } |
| 197 | |
| 198 | if (opt.assets() == 0) { |
| 199 | // Post branchers directly, as no portfolio search requested |
| 200 | switch (opt.branching()) { |
| 201 | case BRANCH_CBS_MAX_SD: |
| 202 | #ifdef GECODE_HAS_CBS |
| 203 | cbsbranch(*this, e); |
| 204 | #endif |
| 205 | case BRANCH_SIZE: |
| 206 | branch(*this, e, INT_VAR_SIZE_MIN(), INT_VAL_MIN()); |
| 207 | break; |
| 208 | case BRANCH_AFC_SIZE: |
| 209 | branch(*this, e, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN()); |
| 210 | break; |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | /// Slave function for portfolio search |
| 215 | virtual bool slave(const MetaInfo& mi) { |
| 216 | if (mi.type() == MetaInfo::PORTFOLIO) { |
nothing calls this directly
no test coverage detected