Example #1
0
void nra_solver::handle_sat_case(box const & b) const {
    // SAT
    DREAL_LOG_FATAL << "Solution:";
    DREAL_LOG_FATAL << b;
    // --proof option
    if (config.nra_proof) {
        config.nra_proof_out.close();
        config.nra_proof_out.open(config.nra_proof_out_name.c_str(), std::ofstream::out | std::ofstream::trunc);
        display(config.nra_proof_out, b, !config.nra_readable_proof, true);
    }
    // --model option
    if (config.nra_model) {
        config.nra_model_out.open(config.nra_model_out_name.c_str(), std::ofstream::out | std::ofstream::trunc);
        if (config.nra_model_out.fail()) {
            cout << "Cannot create a file: " << config.nra_model_out_name << endl;
            exit(1);
        }
        display(config.nra_model_out, b, false, true);
    }
#ifdef SUPPORT_ODE
    // --visualize option
    if (config.nra_json) {
        json traces = {};
        // Need to run ODE pruning operator once again to generate a trace
        for (constraint * const ctr : m_stack) {
            if (ctr->get_type() == constraint_type::ODE) {
                contractor_capd_fwd_full fwd_full(b, dynamic_cast<ode_constraint *>(ctr), config.nra_ODE_taylor_order, config.nra_ODE_grid_size);
                json trace = fwd_full.generate_trace(b, config);
                traces.push_back(trace);
            }
        }
        json vis_json;
        vis_json["traces"] = traces;
        config.nra_json_out << vis_json.dump() << endl;;
    }
#endif
    // For API call
    b.assign_to_enode();
    return;
}