示例#1
0
文件: backend.c 项目: potassco/clingo
bool solve(clingo_control_t *ctl, clingo_solve_result_bitset_t *result) {
  bool ret = true;
  clingo_solve_handle_t *handle;
  clingo_model_t const *model;

  // get a solve handle
  if (!clingo_control_solve(ctl, clingo_solve_mode_yield, NULL, 0, NULL, NULL, &handle)) { goto error; }
  // loop over all models
  while (true) {
    if (!clingo_solve_handle_resume(handle)) { goto error; }
    if (!clingo_solve_handle_model(handle, &model)) { goto error; }
    // print the model
    if (model) { print_model(model); }
    // stop if there are no more models
    else       { break; }
  }
  // close the solve handle
  if (!clingo_solve_handle_get(handle, result)) { goto error; }

  goto out;

error:
  ret = false;

out:
  // free the solve handle
  return clingo_solve_handle_close(handle) && ret;
}
示例#2
0
文件: main.c 项目: lc2casp/lc2casp
int solve(clingo_control_t *ctl) {
    clingo_solve_result_t ret;
    if (report_error(clingo_control_solve(ctl, 0, &on_model, 0, &ret))) { return 0; }
    printf("the solve result is: %d\n", ret);
    return 1;
}