ilp_solution_t::ilp_solution_t( const ilp_problem_t *prob, solution_type_e sol_type, const std::vector<double> &values) : m_ilp(prob), m_solution_type(sol_type), m_optimized_values(values), m_constraints_sufficiency(prob->constraints().size(), false), m_value_of_objective_function(prob->get_value_of_objective_function(values)), m_is_timeout(false) { for (int i = 0; i < prob->constraints().size(); ++i) { const constraint_t &cons = prob->constraint(i); m_constraints_sufficiency[i] = cons.is_satisfied(values); } if (proof_graph() != NULL and phillip() != NULL) { if (proof_graph()->has_timed_out() and m_solution_type != SOLUTION_NOT_AVAILABLE) m_solution_type = phillip()->generator()->do_keep_validity_on_timeout() ? SOLUTION_SUB_OPTIMAL : SOLUTION_NOT_AVAILABLE; if (problem()->has_timed_out() and m_solution_type != SOLUTION_NOT_AVAILABLE) m_solution_type = phillip()->converter()->do_keep_validity_on_timeout() ? SOLUTION_SUB_OPTIMAL : SOLUTION_NOT_AVAILABLE; if (has_timed_out() and m_solution_type != SOLUTION_NOT_AVAILABLE) m_solution_type = phillip()->solver()->do_keep_validity_on_timeout() ? SOLUTION_SUB_OPTIMAL : SOLUTION_NOT_AVAILABLE; } }
void ilp_solution_t::print(std::ostream *os) const { (*os) << "<solution name=\"" << name() << "\" time=\"" << phillip()->get_time_for_sol() << "\" timeout=\"" << (has_timed_out() ? "yes" : "no") << "\">" << std::endl << "<variables num=\"" << m_ilp->variables().size() << "\">" << std::endl; for( int i=0; i<m_ilp->variables().size(); ++i ) { const variable_t& var = m_ilp->variable(i); (*os) << "<variable index=\"" << i << "\" name=\"" << var.name() << "\" coefficient=\""<< var.objective_coefficient() << "\">"<< m_optimized_values[i] <<"</variable>" << std::endl; } (*os) << "</variables>" << std::endl << "<constraints num=\"" << m_ilp->constraints().size() << "\">" << std::endl; for( int i=0; i<m_ilp->constraints().size(); i++ ) { const constraint_t &cons = m_ilp->constraint(i); (*os) << "<constraint index=\"" << i << "\" name=\"" << cons.name() << "\">" << (m_constraints_sufficiency.at(i) ? "1" : "0") << "</constraint>" << std::endl; } (*os) << "</constraints>" << std::endl << "</solution>" << std::endl; }
void ilp_problem_t::print(std::ostream *os) const { (*os) << "<ilp name=\"" << name() << "\" maxmize=\"" << (do_maximize() ? "yes" : "no") << "\" time=\"" << phillip()->get_time_for_ilp() << "\" timeout=\"" << (has_timed_out() ? "yes" : "no"); for (auto attr = m_attributes.begin(); attr != m_attributes.end(); ++attr) (*os) << "\" " << attr->first << "=\"" << attr->second; (*os) << "\">" << std::endl << "<variables num=\"" << m_variables.size() << "\">" << std::endl; for (int i = 0; i < m_variables.size(); i++) { const variable_t &var = m_variables.at(i); (*os) << "<variable index=\"" << i << "\" name=\"" << var.name() << "\" coefficient=\"" << var.objective_coefficient() << "\""; if (is_constant_variable(i)) (*os) << " fixed=\"" << const_variable_values().at(i) << "\""; (*os) << "></variable>" << std::endl; } (*os) << "</variables>" << std::endl << "<constraints num=\"" << m_constraints.size() << "\">" << std::endl; for (int i = 0; i < m_constraints.size(); i++) { const constraint_t &cons = m_constraints.at(i); std::string cons_exp; cons.print(&cons_exp, m_variables); (*os) << "<constraint index=\"" << i << "\" name=\"" << cons.name() << "\">" << cons_exp << "</constraint>" << std::endl; } (*os) << "</constraints>" << std::endl << "</ilp>" << std::endl; }
/** * _dolphin_getc - receive one byte from the parallel port (DD A816) * * This function tries to receive one byte via parallel and returns * it if successful. Returns -1 instead if the device state has * changed. */ static int16_t _dolphin_getc(void) { /* wait until CLOCK is high */ while (!IEC_CLOCK) // A818 if (iec_check_atn()) return -1; set_data(1); // A81F /* start EOI timeout */ start_timeout(86); /* wait until CLOCK is low or 86 microseconds passed */ uint8_t tmp; do { if (iec_check_atn()) return -1; tmp = has_timed_out(); } while (!tmp && IEC_CLOCK); if (tmp) { // A835 /* acknowledge EOI */ set_data(0); delay_us(57); set_data(1); uart_putc('E'); iec_data.iecflags |= EOI_RECVD; /* wait until CLOCK is low - A849 */ while (IEC_CLOCK) if (iec_check_atn()) return -1; } /* read byte */ uint8_t b = parallel_read(); parallel_send_handshake(); set_data(0); return b; }