Example #1
0
/* computeseqcountconstraints3 recursive helper function */
static void
computeseqcountconstraints3r(NCDAPCOMMON* dapcomm, CDFnode* node, CDFnode** candidatep)
{
    CDFnode* candidate;
    CDFnode* compound;
    unsigned int i;

    candidate = NULL;
    compound = NULL;

    for(i=0;i<nclistlength(node->subnodes);i++) {
        CDFnode* subnode = (CDFnode*)nclistget(node->subnodes,i);
        if(subnode->nctype == NC_Structure || subnode->nctype == NC_Grid)
	    compound = subnode; /* save for later recursion */
	else if(subnode->nctype == NC_Atomic)
	    candidate = prefer(candidate,subnode);
    }
    if(candidate == NULL && compound == NULL) {
	PANIC("cannot find candidate for seqcountconstraints for a sequence");
    } else if(candidate != NULL && candidatep != NULL) {
	*candidatep = candidate;
    } else { /* compound != NULL by construction */
	/* recurse on a nested grids or strucures */
        computeseqcountconstraints3r(dapcomm,compound,candidatep);
    }
}
Example #2
0
static void 
optim1(char netstr[], char name[])
{
	char path[STSIZ], rpath[STSIZ];
	register char *cp, *cp2;
	register int tp, nc;
	
	cp = netstr;
	prefer(cp);
	*name  = '\0';
	/*
	 * If the address ultimately points back to us,
	 * just return a null network path.
	 */
	if ((int)strlen(cp) > 1 && cp[strlen(cp) - 2] == LOCAL)
		return;
	while (*cp != 0) {
		*path = '\0';

		tp = ntype(cp[1]);
		nc = cp[1];
		while (*cp && tp == ntype(cp[1])) {
			stradd(path, sizeof (path), *cp++);
			cp++;
		}
		switch (netkind(tp)) {
		default:
			nstrcpy(rpath, sizeof (rpath), path);
			break;

		case IMPLICIT:
			optimimp(path, rpath);
			break;

		case EXPLICIT:
			optimex(path, rpath);
			break;
		}
		for (cp2 = rpath; *cp2 != 0; cp2++) {
			stradd(name, BUFSIZ, *cp2);
			stradd(name, BUFSIZ, nc);
		}
	}
	optiboth(name);
	prefer(name);
}
Example #3
0
Size ScrollView::GetPreferredSize() const
{
  Size prefer(400, 300);

  AbstractView* widget = first();

  if(widget) {
    prefer = widget->GetPreferredSize();
  }

  return prefer;
}
Example #4
0
MirrorWidget::MirrorWidget(Aqpm::Configuration::MirrorType type, QWidget *parent)
        : QWidget(parent)
        , m_ui(new Ui::MirrorWidget)
        , m_type(type)
{
    m_ui->setupUi(this);

    reloadMirrors();

    connect(m_ui->deferButton, SIGNAL(clicked()), this, SIGNAL(defer()));
    connect(m_ui->preferButton, SIGNAL(clicked()), this, SIGNAL(prefer()));
    connect(m_ui->removeButton, SIGNAL(clicked()), this, SIGNAL(remove()));
}
Example #5
0
/* slave 进程 */
void worker()
{
    printf("\tProcessor %d at %s begin work..\n", myid, processor_name);

    MPI_Status status;
    MPI_Request handle;

    int recv_flag = 0;
    int count = 0;
    int upload = 0;

    // 非阻塞接收主进程消息
    MPI_Irecv(selectedGenes, n, MPI_GENETYPE, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &handle);

    while(1)
    {
        // 独立繁衍count代
        count = generations;
        while(count--)
        {
            select();
            crossover();
            mutate();
            evaluate();
            prefer();
            // 若满足终止条件,则向主进程发送最优路径,并结束进程
            if(population[CARDINALITY].fitness <= optimal+margin)
            {
                printf("\tProcessor %d at %s Terminated\n", myid, processor_name);
                MPI_Send(&population[CARDINALITY], 1, MPI_GENETYPE, 0, DONE_TAG, MPI_COMM_WORLD);
                printf("\tProcessor %d at %s exit\n", myid, processor_name);
                return;
            }
            // 探测是否收到主进程的消息
            MPI_Test(&handle, &recv_flag, &status);
            // 若收到主进程的消息
            if(recv_flag)
            {
                printf("\tProcessor %d at %s recv %d\n", myid, processor_name, status.MPI_TAG);

                // 状态重置
                recv_flag = 0;
                // 若接收到DONE_TAG则结束进程
                if(status.MPI_TAG == DONE_TAG)
                {
                    printf("\tProcessor %d at %s exit\n", myid, processor_name);
                    return;
                }
                // 否则,将接收到的优良个体替换种群中最差的个体
                qsort(population, CARDINALITY, sizeof(GeneType), compare);
                for(int i=1; i <= n; i++)
                    assign(&population[CARDINALITY-i], &selectedGenes[i-1]);
                if(selectedGenes[0].fitness < population[CARDINALITY].fitness)
                    assign(&population[CARDINALITY], &selectedGenes[0]);

                // 非阻塞接收主进程消息
                MPI_Irecv(selectedGenes, n, MPI_GENETYPE, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &handle);
            }
        }
        // 繁衍count代后,若没有终止则向主进程发送最优个体
        select_N_best(n);
        MPI_Send(selectedGenes, n, MPI_GENETYPE, 0, PUT_BETTER_TAG, MPI_COMM_WORLD);
        printf("\tProcessor %d at %s upload %d\n", myid, processor_name, upload++);
    }
}
bool SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere, bool aAllowDisambiguation )
{
    BOARD_ITEM* item;
    GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
    GENERAL_COLLECTOR collector;

    // Preferred types (they have the priority when if they are covered by a bigger item)
    const KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, PCB_LINE_T, PCB_MODULE_TEXT_T, EOT };

    if( m_editModules )
        collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::ModuleItems,
                           wxPoint( aWhere.x, aWhere.y ), guide );
    else
        collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::AllBoardItems,
                           wxPoint( aWhere.x, aWhere.y ), guide );

    switch( collector.GetCount() )
    {
    case 0:
        if( !m_additive )
            clearSelection();

        return false;

    case 1:
        toggleSelection( collector[0] );

        return true;

    default:
        // Remove unselectable items
        for( int i = collector.GetCount() - 1; i >= 0; --i )
        {
            if( !selectable( collector[i] ) )
                collector.Remove( i );
        }

        // Check if among the selection candidates there is only one instance of preferred type
        item = prefer( collector, types );
        if( item )
        {
            toggleSelection( item );

            return true;
        }

        // Let's see if there is still disambiguation in selection..
        if( collector.GetCount() == 1 )
        {
            toggleSelection( collector[0] );

            return true;
        }

        else if( aAllowDisambiguation && collector.GetCount() > 1 )
        {
            item = disambiguationMenu( &collector );

            if( item )
            {
                toggleSelection( item );

                return true;
            }
        }
        break;
    }

    return false;
}