int main() { int size = SIZE; int **arr; if (SIZE > MAX_SIZE) { printf("Unsupported size %d. Max supported = %d\n", SIZE, MAX_SIZE); } if (NUM_EP > SIZE) { printf("Number of endpoints %d greater than grid size %d\n", NUM_EP, SIZE); } arr = alloc_n_by_n_array(size); initialize_arr(arr, size); setup_puzzle(ref_arr, arr, size); printf("Problem:\n"); printf("===============\n"); print_arr(arr, size); printf("\nSolutions: \n"); printf("===============\n"); failure_count = 0; solution_count = 0; solve_puzzle(arr, size); printf("\nCompletions but no array full = %d\n", failure_count); printf("\nSolution count = %d\n", solution_count); print_cc(); }
void print_inst(FILE* fptr, inst_t i) { if (i->label) { fprintf(fptr, "%s:", i->label); } if (i->op == OP_BR) { fprintf(fptr, "\t%s", opnames[i->op]); print_cc(fptr, i->ccode); } else fprintf(fptr, "\t%s ", opnames[i->op]); switch (i->op) { /* 3 operands */ case OP_ADD: case OP_AND: case OP_ANDL: case OP_DIV: case OP_LDR: case OP_MUL: case OP_OR: case OP_ORL: case OP_STR: case OP_SUB: print_op(fptr, i->ops[0]); fprintf(fptr, ", "); print_op(fptr, i->ops[1]); fprintf(fptr, ", "); print_op(fptr, i->ops[2]); break; /* 2 operands */ case OP_BR: case OP_SET: case OP_ST: case OP_STI: case OP_LD: case OP_LDI: case OP_LEA: case OP_NOT: case OP_NOTL: print_op(fptr, i->ops[0]); fprintf(fptr, ", "); print_op(fptr, i->ops[1]); break; /* one operand */ case OP_JSRR: case OP_BRA: case OP_JMP: case OP_JSR: print_op(fptr, i->ops[0]); default: break; } fprintf(fptr, "\n"); }
bool generate_conservative_cover(TRel &tr, int kmax, const SS &state_space, const SS &initial_state, list<Region *> &minregs) { set<string> Evs, problem_events; map<string,EvTRel *> tr_map = tr.get_map_trs(); map<string,EvTRel *>::const_iterator itm; for(itm=tr_map.begin(); itm != tr_map.end(); ++itm) { Evs.insert(itm->first); } vector<list<Region *> > CCs(10); int i = 0; do { string cover_event = *(Evs.begin()); set<string> localEvs; localEvs.insert(cover_event); // cout << "event a cobrir: " << cover_event << endl; CCs[i] = find_conservative_component(tr_map[cover_event],tr,kmax ,state_space,localEvs,minregs,problem_events); // cout << "Found a conservative component with " << CCs[i].size() << " places" << endl; if (not CCs[i].empty()) { cout << endl << endl << "# Conservative component " << i << " --------------------"<< endl; print_cc(CCs[i],tr,initial_state,kmax,localEvs); ++i; } set<string> tmpEvs; set_union(localEvs.begin(),localEvs.end(),problem_events.begin(),problem_events.end(),inserter(localEvs, localEvs.begin())); set_difference(Evs.begin(),Evs.end(),localEvs.begin(),localEvs.end(),inserter(tmpEvs, tmpEvs.begin())); Evs = tmpEvs; if (i>=10) CCs.resize(CCs.size() + 10); } while (not Evs.empty()); if (not problem_events.empty()) { list<Region *> cc_problem; print_cc(cc_problem,tr,initial_state,kmax,problem_events); } return true; }