int SockLib::udp_init(int localPort, int windowSize) {
	if (init()) {
		SysLogger::inst()->err("socket init error");
		return -1;
	}
	
	// bind receiving port
	memset(&localAddr, 0, sizeof(localAddr)); /* Zero out structure */
	localAddr.sin_family = AF_INET; /* Internet address family */
	localAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
	localAddr.sin_port = htons(localPort); /* Local port */
	if (bind(sock, (struct sockaddr *) &localAddr, sizeof(localAddr)) == SOCKET_ERROR) {
		SysLogger::inst()->err("bind error");
		return -1;
	}

	dstAddr.sin_port = 0;

	// generate seq num
	seq = 0;
	lastSeq = -1;
	reset_statistics();	
	showFile = false;

	// 
	wSize = windowSize;
	winBuf = new char[wSize * sizeof(UDPPACKET)];
	winPos = 0;
	winBufPos = 0;
	fileSize = 0;
	
	SysLogger::inst()->out("ftp_udp starting on host: [%s:%d]. (Window Size: %d)", 
		hostname, localPort, wSize);
	return 0;
}
Esempio n. 2
0
ValueMap::ValueMap()
  : _nesting(0)
  , _entries(ValueMapInitialSize, NULL)
  , _killed_values()
  , _entry_count(0)
{
  NOT_PRODUCT(reset_statistics());
}
Esempio n. 3
0
bound_propagator::bound_propagator(numeral_manager & _m, allocator & a, params_ref const & p):
    m(_m),
    m_allocator(a), 
    m_eq_manager(m, a) {
    m_timestamp = 0;
    m_qhead     = 0;
    m_conflict  = null_var;
    updt_params(p);
    reset_statistics();
}
 //
 //  Constructor
 //
 LpAstarCore(unsigned rows, unsigned cols, Cell start, Cell goal, string heuristic, Cells const& bad_cells) :
     matrix{ rows, cols },
     start{ start },
     goal{ goal },
     hfunc{ HEURISTICS.at(heuristic) },
     q{ [this](Cell l, Cell r) { return Key{ at(l) } < Key{ at(r) }; } }
 {
     mark_bad_cells(bad_cells);
     mark_h_values_with(goal);   //h value : goal to current
     reset_statistics();
 }
Esempio n. 5
0
double MonteCarlo::do_optimize(unsigned int max_steps) {
    IMP_OBJECT_LOG;
    IMP_CHECK_OBJECT(this);
    if (get_number_of_movers() == 0) {
        IMP_THROW("Running MonteCarlo without providing any"
                  << " movers isn't very useful.",
                  ValueException);
    }

    ParticleIndexes movable = get_movable_particles();

    // provide a way of feeding in this value
    last_energy_ = do_evaluate(movable);
    if (return_best_) {
        best_ = new Configuration(get_model());
        best_energy_ = last_energy_;
    }
    reset_statistics();
    update_states();

    IMP_LOG_TERSE("MC Initial energy is " << last_energy_ << std::endl);

    for (unsigned int i = 0; i < max_steps; ++i) {
        if (get_stop_on_good_score() &&
                get_scoring_function()->get_had_good_score()) {
            break;
        }
        do_step();
        if (best_energy_ < get_score_threshold()) break;
    }

    IMP_LOG_TERSE("MC Final energy is " << last_energy_ << std::endl);
    if (return_best_) {
        // std::cout << "Final score is " << get_model()->evaluate(false)
        //<< std::endl;
        best_->swap_configuration();
        IMP_LOG_TERSE("MC Returning energy " << best_energy_ << std::endl);
        IMP_IF_CHECK(USAGE) {
            IMP_LOG_TERSE("MC Got " << do_evaluate(get_movable_particles())
                          << std::endl);
            /*IMP_INTERNAL_CHECK((e >= std::numeric_limits<double>::max()
                                && best_energy_ >= std::numeric_limits<double>::max())
                               || std::abs(best_energy_ - e)
                               < .01+.1* std::abs(best_energy_ +e),
                               "Energies do not match "
                               << best_energy_ << " vs " << e << std::endl);*/
        }

        return do_evaluate(movable);
    } else {
        return last_energy_;
 auto replan(Cells const& cells_to_toggle = {})
 {
     reset_statistics();
     for (auto c : cells_to_toggle)
     {
         at(c).bad = !at(c).bad;
         if (!at(c).bad)
             update_vertex(at(c));
         else
             at(c).g = at(c).r = huge();
         update_neighbours_of(c);
     }
     compute_shortest_path();
 }
void SockLib::show_statistics(bool ifSend) {
// 	if (ifSend) {
// 		SysLogger::inst()->out("Sender: number of effective bytes sent: %d (%d * %d)", 
// 			sendCnt * sizeof(UDPPACKET), sendCnt, sizeof(UDPPACKET));
// 		SysLogger::inst()->out("Sender: number of packets sent: %d", sendCnt + reSendCnt);
// 		SysLogger::inst()->out("Sender: number of bytes sent: %d (%d * %d)\n", 
// 			(sendCnt + reSendCnt) * sizeof(UDPPACKET), (sendCnt + reSendCnt), sizeof(UDPPACKET));
// 	} else {
// 		SysLogger::inst()->out("Receiver: number of bytes received: %d (%d * %d)\n", 
// 			recvCnt * sizeof(UDPPACKET), recvCnt, sizeof(UDPPACKET));
// 	}
	if (ifSend) {
		SysLogger::inst()->out("Sender: number of effective bytes sent: %d (%d * %d)", 
			fileSize, fileSize / sizeof(UDPPACKET) + 1, sizeof(UDPPACKET));
		SysLogger::inst()->out("Sender: number of packets sent: %d", totalFramesSent);
		SysLogger::inst()->out("Sender: number of bytes sent: %d (%d * %d)\n", 
			(totalFramesSent) * sizeof(UDPPACKET), (totalFramesSent), sizeof(UDPPACKET));
	} else {
		SysLogger::inst()->out("Receiver: number of bytes received: %d (%d * %d)\n", 
			recvCnt * sizeof(UDPPACKET), recvCnt, sizeof(UDPPACKET));
	}
	reset_statistics();
}
 virtual void cleanup() {
     reset_statistics();
     m_solver.reset();
 }
 auto plan()
 {
     reset_statistics();
     initialize();
     compute_shortest_path();
 }
 virtual void cleanup() {
     reset_statistics();
     m_solver.reset();
     m_cancel = false;
 }
Esempio n. 11
0
 cleaner::cleaner(solver & _s):
     s(_s),
     m_last_num_units(0), 
     m_cleanup_counter(0) {
     reset_statistics();
 }
Esempio n. 12
0
IMPCORE_BEGIN_NAMESPACE

MonteCarloMover::MonteCarloMover(kernel::Model *m, std::string name)
    : kernel::ModelObject(m, name), has_move_(false) {
  reset_statistics();
}
Esempio n. 13
0
void init_soar_agent(agent* thisAgent) {

  /* JC ADDED: initialize the rhs function linked list */
  thisAgent->rhs_functions = NIL;

   /* --- initialize everything --- */
  init_symbol_tables(thisAgent);
  create_predefined_symbols(thisAgent);
  init_production_utilities(thisAgent);
  init_built_in_rhs_functions (thisAgent);
  init_rete (thisAgent);
  init_lexer (thisAgent);
  init_firer (thisAgent);
  init_decider (thisAgent);
  init_soar_io (thisAgent);
  init_chunker (thisAgent);
  init_tracing (thisAgent);
  init_explain(thisAgent);  /* AGR 564 */
  select_init(thisAgent);
  predict_init(thisAgent);

  init_memory_pool( thisAgent, &( thisAgent->gds_pool ), sizeof( goal_dependency_set ), "gds" );

  init_memory_pool( thisAgent, &( thisAgent->rl_info_pool ), sizeof( rl_data ), "rl_id_data" );
  init_memory_pool( thisAgent, &( thisAgent->rl_et_pool ), sizeof( rl_et_map ), "rl_et" );
  init_memory_pool( thisAgent, &( thisAgent->rl_rule_pool ), sizeof( rl_rule_list ), "rl_rules" );

  init_memory_pool( thisAgent, &( thisAgent->wma_decay_element_pool ), sizeof( wma_decay_element ), "wma_decay" );
  init_memory_pool( thisAgent, &( thisAgent->wma_decay_set_pool ), sizeof( wma_decay_set ), "wma_decay_set" );
  init_memory_pool( thisAgent, &( thisAgent->wma_wme_oset_pool ), sizeof( wma_pooled_wme_set ), "wma_oset" );
  init_memory_pool( thisAgent, &( thisAgent->wma_slot_refs_pool ), sizeof( wma_sym_reference_map ), "wma_slot_ref" );

  init_memory_pool( thisAgent, &( thisAgent->epmem_wmes_pool ), sizeof( epmem_wme_stack ), "epmem_wmes" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_info_pool ), sizeof( epmem_data ), "epmem_id_data" );
  init_memory_pool( thisAgent, &( thisAgent->smem_wmes_pool ), sizeof( smem_wme_stack ), "smem_wmes" );
  init_memory_pool( thisAgent, &( thisAgent->smem_info_pool ), sizeof( smem_data ), "smem_id_data" );

  init_memory_pool( thisAgent, &( thisAgent->epmem_literal_pool ), sizeof( epmem_literal), "epmem_literals" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_pedge_pool ), sizeof( epmem_pedge ), "epmem_pedges" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_uedge_pool ), sizeof( epmem_uedge ), "epmem_uedges" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_interval_pool ), sizeof( epmem_interval ), "epmem_intervals" );

  thisAgent->epmem_params->exclusions->set_value( "epmem" );
  thisAgent->epmem_params->exclusions->set_value( "smem" );

  thisAgent->smem_params->base_incremental_threshes->set_string( "10" );

#ifdef REAL_TIME_BEHAVIOR
  /* RMJ */
  init_real_time(thisAgent);
#endif


  /* --- add default object trace formats --- */
  add_trace_format (thisAgent, FALSE, FOR_ANYTHING_TF, NIL,
                    "%id %ifdef[(%v[name])]");
  add_trace_format (thisAgent, FALSE, FOR_STATES_TF, NIL,
                    "%id %ifdef[(%v[attribute] %v[impasse])]");
  { Symbol *evaluate_object_sym;
    evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object");
    add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym,
                      "%id (evaluate-object %o[object])");
    symbol_remove_ref (thisAgent, evaluate_object_sym);
  }
  /* --- add default stack trace formats --- */
  add_trace_format (thisAgent, TRUE, FOR_STATES_TF, NIL,
                    "%right[6,%dc]: %rsd[   ]==>S: %cs");
  add_trace_format (thisAgent, TRUE, FOR_OPERATORS_TF, NIL,
                    "%right[6,%dc]: %rsd[   ]   O: %co");

  reset_statistics (thisAgent);

  /* RDF: For gSKI */
  init_agent_memory(thisAgent);
  /* END */

}