void UserDetailsManager::requestDetails( const QStringList & dnList, bool onlyUnknown )
{
	// build a list of DNs that are not already subject to a pending request
	QStringList requestList;
	QValueListConstIterator<QString> end = dnList.end();
	for ( QValueListConstIterator<QString> it = dnList.begin(); it != end; ++it )
	{
		// don't request our own details
		if ( *it == m_client->userDN() )
			break;
		// don't request details we already have unless the caller specified this
		if ( onlyUnknown && known( *it ) )
			break;
		QStringList::Iterator found = m_pendingDNs.find( *it );
		if ( found == m_pendingDNs.end() )
		{
			m_client->debug( QString( "UserDetailsManager::requestDetails - including %1" ).arg( (*it) ) );
			requestList.append( *it );
			m_pendingDNs.append( *it );
		}
	}
	if ( !requestList.empty() )
	{
		GetDetailsTask * gdt = new GetDetailsTask( m_client->rootTask() );
		gdt->userDNs( requestList );
		connect( gdt, SIGNAL( gotContactUserDetails( const GroupWise::ContactDetails & ) ), 
			SLOT( slotReceiveContactDetails( const GroupWise::ContactDetails & ) ) );
		// TODO: connect to gdt's finished() signal, check for failures, expand gdt to maintain a list of not found DNs?
		gdt->go( true );
	}
	else
	{
		m_client->debug( "UserDetailsManager::requestDetails - all requested contacts are already available or pending" );
	}
}
bool Foam::fileFormats::surfaceFormatsCore::checkSupport
(
    const wordHashSet& available,
    const word& ext,
    const bool verbose,
    const word& functionName
)
{
    if (available.found(ext))
    {
        return true;
    }
    else if (verbose)
    {
        wordList toc = available.toc();
        SortableList<word> known(toc.xfer());

        Info<<"Unknown file extension for " << functionName
            << " : " << ext << nl
            <<"Valid types: (";
        // compact output:
        forAll(known, i)
        {
            Info<<" " << known[i];
        }
        Info<<" )" << endl;
    }

    return false;
}
Example #3
0
const Font* FontImpl::lookup(Display* d, const String& name, float scale) {
    const Font* f;
    FontRep* r;
    KnownFonts* k = nil;
    UniqueString uname(name);
    if (fonts()->find(k, uname)) {
	for (ListItr(FontList) i(k->fonts); i.more(); i.next()) {
	    f = i.cur();
	    if (Math::equal(f->impl_->scale_, scale, float(0.0001))) {
		return f;
	    }
	}

	r = find_rep(k->fontreps, d, scale);
	if (r != nil) {
	    return new_font(uname, scale, k, r);
	}
    }

    r = create(d, uname, scale);
    if (r == nil) {
	return nil;
    }
    k = known(k, uname);
    f = new_font(uname, scale, k, r);
    f->impl_->new_rep(k, r);
    f->impl_->entry_ = k;
    return f;
}
void UserDetailsManager::requestDetails( const QStringList & dnList, bool onlyUnknown )
{
	// build a list of DNs that are not already subject to a pending request
	QStringList requestList;
	QStringListIterator it( dnList );
	while ( it.hasNext() )
	{
		QString dn = it.next();
		// don't request our own details
		if ( dn == m_client->userDN() )
			break;
		// don't request details we already have unless the caller specified this
		if ( onlyUnknown && known( dn ) )
			break;
		if ( !m_pendingDNs.contains( dn ) )
		{
			m_client->debug( QString( "UserDetailsManager::requestDetails - including %1" ).arg( dn ) );
			requestList.append( dn);
			m_pendingDNs.append( dn );
		}
	}
	if ( !requestList.empty() )
	{
		GetDetailsTask * gdt = new GetDetailsTask( m_client->rootTask() );
		gdt->userDNs( requestList );
		connect( gdt, SIGNAL(gotContactUserDetails(GroupWise::ContactDetails)), 
			SLOT(slotReceiveContactDetails(GroupWise::ContactDetails)) );
		// TODO: connect to gdt's finished() signal, check for failures, expand gdt to maintain a list of not found DNs?
		gdt->go( true );
	}
	else
	{
		m_client->debug( "UserDetailsManager::requestDetails - all requested contacts are already available or pending" );
	}
}
void ParameterOptimization::optimize_int_parameter(Parameter<int> &parameter, 
						   const bool fullgrid, 
						   const int step){
  printf("Altering %s\n", parameter.get_name().c_str());
  if(!fullgrid)
    apply_to_all_parameters(set_to_best<int>, set_to_best<float>);
  const int min = parameter.get_min();
  const int max = parameter.get_max();
  float step_size = (float) (max - min) / kResolution;
  for(int res_step = 0; res_step < kResolution + 1; ++res_step){
    const int current_value = (int) (0.5 + min + res_step * step_size);
    std::cout << " current value is: " << current_value << std::endl
	      << "while: min:" << min << " max: " << max << std::endl
	      << "and res step: " << res_step
	      << " and step_size: " << step_size << std::endl;
 
    parameter.set_value(current_value);
    const ParameterSet handle = get_current_parameter_handle();
    if(true || !known(handle)){
      //text output -----------
      std::cout << "going to test with: " << std::endl << std::endl;
      printCurrentParameters();
      std::cout << ".. now .." << std::endl << std::endl;
      float result = evaluation_function();
      report_progress();
      std::cout << "just tested with: " << std::endl;
      printCurrentParameters();
      std::cout << "and that's a fact" << std::endl;
      printf("result: %.6f\n\n", result);
      
      // log results
      if (result > best)
        fout << "result is improvement:";
      else
        fout << "results:";
      
      fout << result << endl;
      printCurrentParametersToFile();
      fout << endl;
      fout.flush();
      //text outpus done ----------

      TestResult res( handle, result);
      current_results.push_back(res);
      if(result > best){
	      printf("improvement: %f -> %f\n", best, result);
	      best = result;
	      apply_to_all_parameters(&set_current_as_best<int>, &set_current_as_best<float>);
      }
    }

    if(fullgrid)
      optimize_grid_axis(step + 1);
  }
}
Example #6
0
/* gen_main -- generate the main program */
static void gen_main(void) {
     int i;
     char buf[128];

     if (known("MAIN")) return;

     err_file = (char *) "main program";

     /* For completeness, generate a header listing all loaded modules. */
     gen_inst("MODULE %%Main 0 0");
     for (i = 0; i < nmodules; i++) {
	  if (strcmp(module[i].m_name, "_Builtin") == 0 
	      || !module[i].m_needed) continue;
	  gen_inst("IMPORT %s %#x", module[i].m_name, module[i].m_check);
     }
     gen_inst("ENDHDR");

     gen_inst("PROC MAIN 0 4 0");
     /* Code to call each module body */
     for (i = 0; i < nmodules; i++) {
	  if (!module[i].m_needed) continue;
	  sprintf(buf, "%s.%%main", module[i].m_name);
	  if (known(buf)) {
	       gen_inst("CONST %s", buf);
	       gen_inst("CALL 0");
	  }
     }
     gen_inst("RETURN");
     gen_inst("END");

     /* Make global pointer map */
     gen_inst("DEFINE GCMAP");
     for (i = 0; i < nmodules; i++) {
	  if (!module[i].m_needed) continue;
	  sprintf(buf, "%s.%%gcmap", module[i].m_name);
	  if (known(buf)) {
	       gen_inst("WORD GC_MAP");
	       gen_inst("WORD %s", buf);
	  }
     }
     gen_inst("WORD GC_END");
}
  void ParameterOptimization::optimize_float_parameter(Parameter<float> &parameter,
						       bool fullgrid,
						       const int step){
  printf("Altering %s\n", parameter.get_name().c_str());
  if(!fullgrid)
    apply_to_all_parameters(&set_to_best<int>, &set_to_best<float>);
  const float min = parameter.get_min();
  const float max = parameter.get_max();
  float step_size = (max - min) / (float)kResolution;
  for(int res_step = 0; res_step < kResolution + 1; ++res_step){
    const float current_value = min + res_step * step_size;
    parameter.set_value(current_value);
    const ParameterSet handle = get_current_parameter_handle();
    if(true || !known(handle)){
      std::cout << "going to test with: " << std::endl << std::endl;
      printCurrentParameters();
      std::cout << ".. now .." << std::endl << std::endl;
      float result = evaluation_function();
      report_progress();
      std::cout << "just tested with: " << std::endl;
      printCurrentParameters();
      std::cout << "and that's a fact" << std::endl;
      printf("result: %.6f\n\n", result);

      // log results
      result > best? fout << "result is improvement:" : fout << "results:";
      fout << result << endl;
      printCurrentParametersToFile();
      fout << endl;
      fout.flush();

      TestResult res( handle, result);
      current_results.push_back(res);
      if(result > best){
	printf("improvement: %f -> %f\n", best, result);
	best = result;
	//parameter.set_current_as_best();
	apply_to_all_parameters(&set_current_as_best<int>, 
				&set_current_as_best<float> );
      }
    }
    if(fullgrid)
      optimize_grid_axis(step + 1);
  }
}
Example #8
0
FontRep* FontImpl::rep(Display* d) {
    FontRep* r;
    for (ListItr(FontRepList) i(*replist_); i.more(); i.next()) {
	r = i.cur();
	if (r->display_ == d) {
	    return r;
	}
    }

    KnownFonts* k = nil;
    if (fonts()->find(k, *name_)) {
	r = find_rep(k->fontreps, d, scale_);
	if (r != nil) {
	    attach(r);
	    return r;
	}
    }

    r = create(d, *name_, scale_);
    if (r != nil) {
	new_rep(known(k, *name_), r);
    }
    return r;
}
  int pid, stopsig, result;

  if (!PyArg_Parse(args, "(ii)", &pid, &stopsig))
    return NULL;

  result = atcallstop(pid, stopsig);
  if (result == -1)
    return posix_error();
  return Py_BuildValue("i", result);
}


static char subterfugue_mainloop__doc__[] = 
"mainloop(pid) -> (wpid, status, beforecall)\n\
Run the optimized main loop until something interesting happens.\n\
Process 'pid' must already be known (in allflags), and 'insyscall' and\n\
'startup' must be false.";

static PyObject *
subterfugue_mainloop(PyObject *self, PyObject *args)
{
  int pid, wpid, status, scno, eax, waitchannelhack;
  int beforecall = -1;

  if (!PyArg_Parse(args, "(ii)", &pid, &waitchannelhack))
    return NULL;

  numtraced++;

  while (1) {
    int result;
Example #10
0
Approximator::Approximator(Structure& structure, DenseSetStore& sets,
                           WorkerPool& worker_pool)
    :  // structure
      m_structure(structure),
      m_item_dim(structure.carrier().item_dim()),
      m_top(structure.nullary_function("TOP").find()),
      m_bot(structure.nullary_function("BOT").find()),
      m_less(structure.binary_relation("LESS")),
      m_nless(structure.binary_relation("NLESS")),
      // dense set stores
      m_sets(sets),
      m_empty_set(sets.store(std::move(DenseSet(m_item_dim)))),
      m_known(1 + m_item_dim),
      m_unknown(),
      // lazy map caches
      m_disjoint_cache(worker_pool,
                       [this](const std::pair<SetId, SetId>& pair) {
          return m_sets.load(pair.first).disjoint(m_sets.load(pair.second))
                     ? Trool::TRUE
                     : Trool::FALSE;
      }),
      m_union_cache(worker_pool, [this](const std::vector<SetId>& sets) {
          const size_t count = sets.size();
          POMAGMA_ASSERT1(count >= 2, "too few sets: " << count);
          DenseSet val(m_item_dim);
          val.set_union(m_sets.load(sets[0]), m_sets.load(sets[1]));
          for (size_t i = 2; i < count; ++i) {
              val += m_sets.load(sets[i]);
          }
          return m_sets.store(std::move(val));
      }),
      m_nullary_cache(),
      m_binary_cache() {
    POMAGMA_ASSERT(m_top, "TOP is not defined");
    POMAGMA_ASSERT(m_bot, "BOT is not defined");

    POMAGMA_INFO("Inserting LESS and NLESS in DenseSetStore");
    for (auto iter = m_structure.carrier().iter(); iter.ok(); iter.next()) {
        const Ob ob = *iter;
        m_known[ob][ABOVE] = m_sets.store(m_less.get_Lx_set(ob));
        m_known[ob][BELOW] = m_sets.store(m_less.get_Rx_set(ob));
        m_known[ob][NABOVE] = m_sets.store(m_nless.get_Lx_set(ob));
        m_known[ob][NBELOW] = m_sets.store(m_nless.get_Rx_set(ob));
    }
    m_unknown[ABOVE] = m_known[m_top][ABOVE];
    m_unknown[BELOW] = m_known[m_bot][BELOW];
    m_unknown[NABOVE] = m_empty_set;
    m_unknown[NBELOW] = m_empty_set;

    POMAGMA_INFO("Initializing nullary_function cache");
    for (const auto& i : signature().nullary_functions()) {
        const std::string& name = i.first;
        Ob ob = i.second->find();
        Approximation approx = ob ? known(ob) : unknown();
        POMAGMA_INSERT(m_nullary_cache, name, approx);
    }

    POMAGMA_INFO("Initializing binary_function cache");
    for (const auto& i : signature().binary_functions()) {
        const auto& fun = *i.second;
        const uint64_t hash = hash_name(i.first);
        typedef SetPairToSetCache Cache;
        for (Parity p : {ABOVE, BELOW}) {
            POMAGMA_INSERT(
                m_binary_cache, CacheKey(hash, VAL, p),
                new Cache(worker_pool,
                          [this, &fun, p](const std::pair<SetId, SetId>& x) {
                    return function_lhs_rhs(fun, x.first, x.second, p);
                }));
        }
        for (Parity p : {NABOVE, NBELOW}) {
            POMAGMA_INSERT(
                m_binary_cache, CacheKey(hash, RHS, p),
                new Cache(worker_pool,
                          [this, &fun, p](const std::pair<SetId, SetId>& x) {
                    return function_lhs_val(fun, x.first, x.second, p);
                }));
            POMAGMA_INSERT(
                m_binary_cache, CacheKey(hash, LHS, p),
                new Cache(worker_pool,
                          [this, &fun, p](const std::pair<SetId, SetId>& x) {
                    return function_rhs_val(fun, x.first, x.second, p);
                }));
        }
    }

    POMAGMA_INFO("Initializing symmetric_function cache");
    for (const auto& i : signature().symmetric_functions()) {
        const auto& fun = *i.second;
        const uint64_t hash = hash_name(i.first);
        typedef SetPairToSetCache Cache;
        for (Parity p : {ABOVE, BELOW}) {
            POMAGMA_INSERT(
                m_binary_cache, CacheKey(hash, VAL, p),
                new Cache(worker_pool,
                          [this, &fun, p](const std::pair<SetId, SetId>& x) {
                    return function_lhs_rhs(fun, x.first, x.second, p);
                }));
        }
        for (Parity p : {NABOVE, NBELOW}) {
            auto* cache = new Cache(
                worker_pool, [this, &fun, p](const std::pair<SetId, SetId>& x) {
                    return function_lhs_val(fun, x.first, x.second, p);
                });
            POMAGMA_INSERT(m_binary_cache, CacheKey(hash, RHS, p), cache);
            POMAGMA_INSERT(m_binary_cache, CacheKey(hash, LHS, p), cache);
        }
    }
}