示例#1
0
文件: sets.c 项目: tcsiwula/c_code
/* =============================================================================
 Function:      =        Difference
 Purpose:       =        Difference the contents of the arrays A and B into
                         array C
 ==============================================================================
  Input arg:    =        1. struct set_s* a_p:  pointer to head of list a_p
                =        2. int asize:  size of elements in list a_p.
                =        3. struct set_s* b_p:  pointer to head of list b_p
                =        4. int bsize:  size of elements in list b_p.
                =        5. struct set_s* c_p:  pointer to head of list c_p
                =        6. int csize:  size of elements in list c_p.
                =        7. struct set_s* C:    pointer to head of list C
  ==============================================================================
  Return val:   =        1. struct set_s* C:  pointer to head of list C
  ============================================================================*/
 struct set_s* Difference(struct set_s* a_p, int asize, struct set_s* b_p,
                    int bsize, struct set_s* c_p, int csize, struct set_s* C )
 {
     C = malloc(csize * sizeof(struct set_s));
     C->next_p = NULL;
     c_p = malloc(csize * sizeof(struct set_s));
     c_p->next_p = NULL;

     while (a_p != NULL &&  b_p != NULL)
         if (a_p->element <= b_p->element)
         {
           if (!Member(b_p, a_p->element))
           {
               c_p = Append(&C, c_p, a_p->element);
           }
             a_p = Advance(a_p);
         }
         else
         {  // b_p->data < a_p->data
             b_p = Advance(b_p);
         }

     while (a_p != NULL)
     {
       if (!Member(b_p, a_p->element))
       {
         c_p = Append(&C, c_p, a_p->element);
       }
       a_p = Advance(a_p);
     }
     return c_p;
 }  /* Difference */
示例#2
0
void Base::PrintGeneratorLevel(Event const& event, bool signature) const
{
    INFO0;
    for (auto const & particle : event.GenParticles()) {
        auto family = particle.Info().Family();
        if (signature && family.Member(Relative::step_mother).Id() == 0) continue;
        auto id = boca::Name(family.Member(Relative::particle).Id());
        auto mother = boca::Name(family.Member(Relative::mother).Id());
        auto mother2 = boca::Name(family.Member(Relative::step_mother).Id());
        ERROR(id, mother, mother2);
    }
}
示例#3
0
Model::Model() {
// +++ NODES +++
this->nodes.push_back(Node(1, "", 0, 3, 0));
this->nodes.push_back(Node(2, "", 0, 3, 5));
this->nodes.push_back(Node(3, "", 0, 0, 0));
this->nodes.push_back(Node(4, "", 0, 0, 5));
this->nodes.push_back(Node(5, "", 5, 0, 0));
this->nodes.push_back(Node(6, "", 5, 0, 5));
this->nodes.push_back(Node(7, "", 0, 0, 0.5));
this->nodes.push_back(Node(8, "", 4.5, 0, 5));
this->nodes.push_back(Node(9, "", 0, 0, 1));
this->nodes.push_back(Node(10, "", 0, 2.5, 5));
// +++ MEMBERS +++
this->members.push_back(Member(1, "C1", 1, 2, 0, 0, 0, "STZ RUSSIAN p_col_k 1 TMP 1.2e-005"));
this->members.push_back(Member(2, "C2", 3, 7, 0, 0, 0, "STZ RUSSIAN p_col_k 1 TMP 1.2e-005"));
this->members.push_back(Member(3, "C3", 5, 6, 0, 0, 90, "STZ RUSSIAN p_wide_h 5 TMP 1.2e-005"));
this->members.push_back(Member(4, "B1", 4, 8, 0, 0, 0, "STZ RUSSIAN p_norm_b 14 TMP 1.2e-005"));
this->members.push_back(Member(5, "B2", 2, 4, 0, 0, 0, "STZ RUSSIAN p_norm_b 14 TMP 1.2e-005"));
this->members.push_back(Member(6, "Brace 1", 7, 8, 0, 0, 0, "STZ RUSSIAN diam 390 TMP 1.2e-005"));
this->members.push_back(Member(7, "Brace 2", 9, 10, 0, 0, 0, "STZ RUSSIAN diam 390 TMP 1.2e-005"));
this->members.push_back(Member(8, "C2", 7, 9, 0, 0, 0, "STZ RUSSIAN p_col_k 1 TMP 1.2e-005"));
this->members.push_back(Member(9, "C2", 9, 4, 0, 0, 0, "STZ RUSSIAN p_col_k 1 TMP 1.2e-005"));
this->members.push_back(Member(10, "B1", 8, 6, 0, 0, 0, "STZ RUSSIAN p_norm_b 14 TMP 1.2e-005"));
// +++ RESTRAINTS +++
this->restraints.push_back(Restraint(1, 0));
this->restraints.push_back(Restraint(3, 0));
this->restraints.push_back(Restraint(5, 0));
// +++ LOAD CASES +++
std::vector <double> massMatrixVector;
this->loadCases.push_back(LoadCase(1, "DL", "Type=0  Mode=1  LongTime=1  ReliabilityFactor=1.05" ));
this->loadCases.push_back(LoadCase(2, "LL", "Type=0  Mode=1  LongTime=1  ReliabilityFactor=1.05" ));
massMatrixVector.clear();
massMatrixVector.push_back(0);
massMatrixVector.push_back(1.2);
massMatrixVector.push_back(1.5);
this->loadCases.push_back(LoadCase(3,"Wind", "Type=2  ReliabilityFactor=1.1  21 5 1  1 3 0 0 0 5 18 1 0 0.3 1", massMatrixVector));
// +++ LOADS +++
std::vector <double> loadVector;
loadVector.clear();
loadVector.push_back(14.3);
this->loads.push_back(Load(1, 6, 0, 1, loadVector));
loadVector.clear();
loadVector.push_back(-3.6);
loadVector.push_back(1);
this->loads.push_back(Load(1, 4, 15, 3, loadVector));
loadVector.clear();
loadVector.push_back(6.6);
this->loads.push_back(Load(2, 2, 0, 5, loadVector));
};
示例#4
0
文件: sets.c 项目: tcsiwula/c_code
/*==============================================================================
 Function:     =        Union
 Purpose:      =        Union the contents of the arrays A and B into array C
 ==============================================================================
 Input arg:    =        1. struct set_s* a_p:  pointer to head of list a_p
               =        2. int asize:  size of elements in list a_p.
               =        3. struct set_s* b_p:  pointer to head of list b_p
               =        4. int bsize:  size of elements in list b_p.
               =        5. struct set_s* c_p:  pointer to head of list c_p
               =        6. int csize:  size of elements in list c_p.
               =        7. struct set_s* C:    pointer to head of list C
 ==============================================================================
 Return val:   =        1. struct set_s* C:  pointer to head of list C
 =============================================================================*/
struct set_s* Union(struct set_s* a_p, int asize, struct set_s* b_p, int bsize,
                    struct set_s* c_p, int csize, struct set_s* C )
{
    C = malloc(csize * sizeof(struct set_s));
    C->next_p = NULL;
    c_p = malloc(csize * sizeof(struct set_s));
    c_p->next_p = NULL;

    while (a_p != NULL &&  b_p != NULL)
        if (a_p->element <= b_p->element)
        {
          if (!Member(C, a_p->element))
          {
              c_p = Append(&C, c_p, a_p->element);
          }
            a_p = Advance(a_p);
        }
        else
        {  // b_p->data < a_p->data
          if (!Member(C, b_p->element))
          {
            c_p = Append(&C, c_p, b_p->element);
          }
            b_p = Advance(b_p);
        }
        // else
        // // case ==
        // // advance both

    while (a_p != NULL)
    {
      if (!Member(C, a_p->element))
      {
        c_p = Append(&C, c_p, a_p->element);
      }
      a_p = Advance(a_p);
    }

    while (b_p != NULL)
    {
      if (!Member(C, b_p->element))
      {
        c_p = Append(&C, c_p, b_p->element);
      }
      b_p = Advance(b_p);
    }
    return c_p;
}  /* Union */
示例#5
0
void MemberModel::appendMember()
{
    int row = rowCount();
    QModelIndex rowIndex = index(row,0);
    beginInsertRows(rowIndex, row, row );
    m_memberArray.appendMember(Member(m_memberArray.headerSize()));
    endInsertRows();
}
void UtilitiesView::setup(int raceTrack){
    //Caricamento tabella tempi
    QSqlQuery q(MainWindow::database);
    q.prepare("SELECT COUNT(*) FROM GPSCoord WHERE CodCircuito = :id");
    q.bindValue(":id",raceTrack);
    q.exec();
    q.next();

    QStringList header;
    header<<"Trascorso"<<"Giro"<<"Gap";
    for(int i=0; i<q.value(0).toInt(); i++){
        header<<QString("Inter. %1").arg(i+1);
    }
    ui->timeTable->setColumnCount(header.count());
    ui->timeTable->setHorizontalHeaderLabels(header);

    GPSSettings settings;
    timeChannel = settings.getSpecialChannel(TIME_CHANNEL);
    lapChannel = settings.getSpecialChannel(LAP_CHANNEL);
    waypointChannel = settings.getSpecialChannel(WAYPOINT_CHANNEL);

    //Caricamento tabella statistiche
    QSqlQueryModel *columnModel = new QSqlQueryModel;
    columnModel->setQuery("SELECT CanID, Nome FROM Canale "
                          "WHERE (CodTipoDato=1 OR CodTipoDato=2) AND (CodTipoIO=1 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->channelList->setModel(columnModel);
    ui->channelList->setModelColumn(1);

    //Caricamento invio msg CAN
    QSqlQueryModel *outputModel = new QSqlQueryModel;
    outputModel->setQuery("SELECT CanID, Nome FROM Canale WHERE (CodTipoIO=2 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->outChannelCombo->setModel(outputModel);
    ui->outChannelCombo->setModelColumn(1);

    statsUpdate->start();

    //Caricamento chiamata team
    //Member::lastCallID = 0;
    QListWidgetItem *item;
    q.exec("SELECT Cognome, Nome, Ruolo,Tel FROM Team ORDER BY Ruolo,Cognome,Nome");
    ui->teamList->clear();
    teamMembers.clear();
    while(q.next()){
        item = new QListWidgetItem(
                    QIcon(":/images/icons/nocall.png"),
                    QString("%1 %2 (%3)")
                        .arg(q.value(0).toString()).arg(q.value(1).toString()).arg(q.value(2).toString()),
                    ui->teamList
                    );
        ui->teamList->addItem(item);
        teamMembers.append(Member(-1,CALL_DISCONNECT,q.value(3).toString()));
    }

}
示例#7
0
void performMemberOperation(int operationValue,int n)
{
	int i;
	for (i = 0; i < operationValue; i++)
	{
		int randomNumber = rand() % n;
		Member(randomNumber,head_p);
		//printf("%s %d %d\n", "did it - ",i,randomNumber);
	}


}
示例#8
0
/*-----------------------------------------------------------------*/
int main(void) {
   char command;
   int  value;
   struct list_node_s* head_p = NULL;  
      /* start with empty list */

   command = Get_command();
   while (command != 'q' && command != 'Q') {
      switch (command) {
         case 'i': 
         case 'I': 
            value = Get_value();
            head_p = Insert(head_p, value);
            break;
         case 'p':
         case 'P':
            Print(head_p);
            break;
         case 'm': 
         case 'M':
            value = Get_value();
            if (Member(head_p, value))
               printf("%d is in the list\n", value);
            else
               printf("%d is not in the list\n", value);
            break;
         case 'd':
         case 'D':
            value = Get_value();
            head_p = Delete(head_p, value);
            break;
         case 'f':
         case 'F':
            head_p = Free_list(head_p);
            break;
         default:
            printf("There is no %c command\n", command);
            printf("Please try again\n");
      }
      command = Get_command();
   }

   head_p = Free_list(head_p);

   return 0;
}  /* main */
void* Thread_work(void* rank)
{
long my_rank = (long) rank;
int i, val;
double which_op;
unsigned seed = my_rank + 1;
int my_member=0, my_insert=0, my_delete=0;
int ops_per_thread = total_ops/thread_count;
for (i = 0; i < ops_per_thread; i++)
   {
   which_op = my_drand(&seed);
   val = my_rand(&seed) % MAX_KEY;
   if (which_op < porcentaje_busqueda)
   {
#     ifdef DEBUG
      printf("Hilo %ld > Buscando %d\n", my_rank, val);
#     endif
      Member(val);
      my_member++;
   }
   else if (which_op < porcentaje_busqueda + porcentaje_insercion)
   {
#     ifdef DEBUG
      printf("Hilo %ld > Insertando %d\n", my_rank, val);
#     endif
      Insert(val);
      my_insert++;
   }
   else 
   {
#     ifdef DEBUG
      printf("Hilo %ld > Borrando %d\n", my_rank, val);
#     endif
      Delete(val);
      my_delete++;
   }
}

   pthread_mutex_lock(&count_mutex);
   total_miembro += my_member;
   total_insertar += my_insert;
   total_borrado += my_delete;
   pthread_mutex_unlock(&count_mutex);

   return NULL;
}
示例#10
0
void* Thread_work(void* rank)
{

   long my_rank = (long) rank;
   int i;
   double which_op;
   int my_member=0, my_insert=0, my_delete=0;
   int ops_per_thread = operations/thread_count;

   for (i = 0; i < ops_per_thread; i++) {
      which_op = (my_rank*ops_per_thread) + i+1;

      if (which_op <= (double)mMemberOps) {
         pthread_rwlock_rdlock(&rwlock);
         int randomNumber = rand() % nValues;
         Member(randomNumber,head_p);
         pthread_rwlock_unlock(&rwlock);
         my_member++;
      } else if (which_op <= (double)mMemberOps + (double)mInsertOps) {
         pthread_rwlock_wrlock(&rwlock);
         Insert(nValues+i+1,&head_p);
         pthread_rwlock_unlock(&rwlock);
         my_insert++;
      } else { /* delete */
         pthread_rwlock_wrlock(&rwlock);
         int randomNumber = rand() % nValues;
         Delete(randomNumber,&head_p);
         pthread_rwlock_unlock(&rwlock);
         my_delete++;
      }
   }  /* for */

   pthread_mutex_lock(&count_mutex);
   member_total += my_member;
   insert_total += my_insert;
   delete_total += my_delete;
   pthread_mutex_unlock(&count_mutex);

   return NULL;

}
示例#11
0
文件: sets.c 项目: tcsiwula/c_code
/*
 ==============================================================================
 Function:     =        Intersection
 Purpose:      =        Intersection the contents of the arrays A and B into
                        array C
 ==============================================================================
 Input arg:    =        1. struct set_s* a_p:  pointer to head of list a_p
               =        2. int asize:  size of elements in list a_p.
               =        3. struct set_s* b_p:  pointer to head of list b_p
               =        4. int bsize:  size of elements in list b_p.
               =        5. struct set_s* c_p:  pointer to head of list c_p
               =        6. int csize:  size of elements in list c_p.
               =        7. struct set_s* C:    pointer to head of list C
 ==============================================================================
 Return val:   =        1. struct set_s* C:  pointer to head of list C
 =============================================================================*/
 struct set_s* Intersection(struct set_s* a_p, int asize, struct set_s* b_p,
                    int bsize, struct set_s* c_p, int csize, struct set_s* C )
 {
     C = malloc(csize * sizeof(struct set_s));
     C->next_p = NULL;
     c_p = malloc(csize * sizeof(struct set_s));
     c_p->next_p = NULL;

     while (a_p != NULL &&  b_p != NULL)
         if (a_p->element <= b_p->element)
         {
           if (Member(b_p, a_p->element))
           {
               c_p = Append(&C, c_p, a_p->element);
           }
             a_p = Advance(a_p);
         }
         else
         {  // b_p->data < a_p->data
           if (Member(a_p, b_p->element))
           {
             c_p = Append(&C, c_p, b_p->element);
           }
             b_p = Advance(b_p);
         }

     while (a_p != NULL)
     {
       if (Member(b_p, a_p->element) && !Member(C, b_p->element))
       {
         c_p = Append(&C, c_p, a_p->element);
       }
       a_p = Advance(a_p);
     }

     while (b_p != NULL)
     {
       if (Member(a_p, b_p->element)  && !Member(C, b_p->element))
       {
         c_p = Append(&C, c_p, b_p->element);
       }
       b_p = Advance(b_p);
     }
    //  c_p = c_p;
     return c_p;
 }  /* Intersection */
void* Thread_Function(void* rank) {
	int i, val;
	
	int my_member=0;
	int my_insert=0;
	int my_delete=0;
	
	int ops_per_thread = m/thread_count;

	for (i = 0; i < ops_per_thread; i++) {
		float operation_choice = (rand()%10000/10000.0);
		val = rand()%MAX_KEY;
	  
		if (operation_choice < mMember) {
			pthread_mutex_lock(&mutex);
			Member(val);
			pthread_mutex_unlock(&mutex);
			my_member++;
		} else if (operation_choice < mMember + mInsert) {
			pthread_mutex_lock(&mutex);
			Insert(val);
			pthread_mutex_unlock(&mutex);
			my_insert++;
		} else {
			pthread_mutex_lock(&mutex);
			Delete(val);
			pthread_mutex_unlock(&mutex);
			my_delete++;
		}
	}

	pthread_mutex_lock(&count_mutex);
	member_count += my_member;
	insert_count += my_insert;
	delete_count += my_delete;
	pthread_mutex_unlock(&count_mutex);
	return NULL;
}
示例#13
0
/*-----------------------------------------------------------------*/
int main(void) {
   char command;
   int  value;
   struct list_node_s* head_p = NULL;  /* start with empty list */

   command = Get_command();
   while (command != 'q' && command != 'Q') {
      switch (command) {
         case 'i': 
         case 'I': 
            value = Get_value();
            Insert(value, &head_p);  /* Ignore return value */
            break;
         case 'p':
         case 'P':
            Print(head_p);
            break;
         case 'm': 
         case 'M':
            value = Get_value();
            Member(value, head_p);   /* Ignore return value */
            break;
         case 'd':
         case 'D':
            value = Get_value();
            Delete(value, &head_p);  /* Ignore return value */
            break;
         default:
            printf("There is no %c command\n", command);
            printf("Please try again\n");
      }
      command = Get_command();
   }
   Free_list(&head_p);

   return 0;
}  /* main */
示例#14
0
/*-----------------------------------------------------------------*/
void* Thread_work(void* rank) {
   long my_rank = (long) rank;
   int i, val;
   double which_op;
   unsigned seed = my_rank + 1;
   int my_member=0, my_insert=0, my_delete=0;
   int ops_per_thread = total_ops/thread_count;

   for (i = 0; i < ops_per_thread; i++) {
      which_op = my_drand(&seed);
      val = my_rand(&seed) % MAX_KEY;
      if (which_op < search_percent) {
         pthread_mutex_lock(&mutex);
         Member(val);
         pthread_mutex_unlock(&mutex);
         my_member++;
      } else if (which_op < search_percent + insert_percent) {
         pthread_mutex_lock(&mutex);
         Insert(val);
         pthread_mutex_unlock(&mutex);
         my_insert++;
      } else { /* delete */
         pthread_mutex_lock(&mutex);
         Delete(val);
         pthread_mutex_unlock(&mutex);
         my_delete++;
      }
   }  /* for */

   pthread_mutex_lock(&count_mutex);
   member_total += my_member;
   insert_total += my_insert;
   delete_total += my_delete;
   pthread_mutex_unlock(&count_mutex);

   return NULL;
}  /* Thread_work */
示例#15
0
void Heuristic_Schedule_MATCHING()

{
   struct List *cut,                                /*Op'en eines Matchings*/
	       *updatelist,	                    /*local_heads aufdatieren */
	       *help,
	       *help1;     
   int         i, 
	       n, 
	       j,
	       dif1,
	       dif2,
	       readytime,                           /* Fertigstellungszeit    */
	       c_max,
	       sum,
	       //prior_op,                            /* Op'en fuer CriticalPath*/
	       op,
	       pos_path,                            /* lok. fuer PathPos */
	       iter,                                /*zaehlt betrachtete Op'en*/
	       mate[MaxNumOfJobs+1],                /* Zuordnung              */
	       c[MaxNumOfJobs+1][MaxNumOfMachines+1],
	       path_critical[MaxNumOfOperations+1]; /*darin steht krit.Pfad erst 
						      in umgek. Reihenfolge*/		


   cut = updatelist = NIL;

   for ( i = 0; i <= NumOfJobs; ++i )
      joblist[i] = NIL;
   for ( i = 0; i <= NumOfMachines; ++ i )
      maschlist[i] = NIL;

   n = Max(NumOfJobs,NumOfMachines);
   iter = 0;

   for ( i = 1; i <= NumOfOperations; ++i )
   {
      num_of_pred[i] = SonNode->num_of_conj_pred[i] +
		       SonNode->num_of_disj_pred[i];
      num_of_succ[i] = SonNode->num_of_conj_succ[i] +
		       SonNode->num_of_disj_succ[i];
      local_head[i] = Head[i];
      obtained[i] = 0;
   }

   /* Bei einem nichtquadrat. Problem wird die Zeitmatrix durch (m-n) 
      zusaetzliche Zeilen bzw. (n-m) zusaetzliche Spalten, falls n<m bzw.
      m<n zu einem quadrat. Problem erweitert. Die neuen Matrixelemente
      bekommen den Wert Null.
   */
   dif1 = n - NumOfJobs;
   dif2 = n - NumOfMachines;

   for ( i = NumOfJobs + 1; i <= NumOfJobs + dif1; i++ )
      for ( j = 1 ; j <= NumOfMachines; j++ )
	 c[i][j] = 0;

   for ( i = 1; i <= NumOfJobs; i++ )
      for ( j = NumOfMachines + 1 ; j <= NumOfMachines + dif2; j++ )
	 c[i][j] = 0;


   /* Diese while-Schleife bricht ab, wenn alle Op'en betrachtet wurden
      ( iter = NumOfOperations ). Jedesmal, wenn eine Op in cut eingefuegt 
      wird, wird iter um eins erhoeht.
   */
   while ( iter < NumOfOperations )
   {
      /* Einlesen der Zeitmatrix :
	 Nichteinplanbare Operationen ausschliessen:
	   Op'en, deren Vorgaenger noch nicht alle eingeplant sind 
	   (num_of_pred > 0) muessen fuer das Matching ausgeschlos-
	   sen werden;
	   Op'en, die bereits im cut waren (num_of_pred = -1), die also ein 
	   Matching bildeten, ebenfalls ausschliessen;
	 Op'en, deren Vorgaenger alle eingeplant sind (num_of_pred = 0) 
	 werden fuer das Matching zugelassen;
      */
      sum = 1;

      for ( i = 1; i <= NumOfJobs; i++ )
	 for ( j = 1; j <= NumOfMachines; j++ )
	 {
	    if ( num_of_pred[sum] == 0 )
	       c[i][j] = minmax_match*OpData[sum].process_time;  
	    else
	       c[i][j] = MaxInt;
	    sum++;
	 }

      /* Loesen des Matchingproblems
      */
      WeightMatch(n, c, mate);
      for ( i = 1; i <= n; i++ )
      {
	 j = mate[i];

	 /* n<m :  mate[i] = j wird fuer i > NumOfJobs unterdrueckt
	    m<n :  mate[i] = j wird fuer j > NumOfMachines unterdrueckt
	 */
	 if ( i <= NumOfJobs  &&  j <= NumOfMachines )
	 {
	    /* Matrixschreibweise fuer Op'en --> einfache Durchnumerierung 
	    */
	    op = FindOpNr(i,j);

	    /* die Op'en des optimalen Matchings stehen in cut
	    */
	    if ( num_of_pred[op] == 0 )
	    {
	       cut = Insert(cut,op);
	       /* Op'en des Matchings werden fuer's folgende ausgeschlossen
	       */
	       num_of_pred[op]--;
	       iter++;

	       /* konj./disj. Nachfolger der Op'en des Matchings werden fuer 
		  folgendes zugelassen, wenn die Anzahl ihrer Vorgaenger auf
		  Null reduziert wird.
	       */
	       help = ConjArcs->succ[op];
	       while ( help != NIL )
	       {
		  num_of_pred[help->number]--;
		  help = help->next;
	       }

	       help = DisjArcs->succ[op];
	       while ( help != NIL )
	       {
		  num_of_pred[help->number]--;
		  help = help->next;
	       }
	    }
	 }
      }

      help = cut;
      while ( help != NIL )
      /* 1. Die Op'en des cut werden in die Job- u. Maschinenreihenfolgen
	    eingereiht.
	 2. Aufdatieren:
	    bei Op'en, die nach den Op'en des Matchings bearbeitet werden,
	    muessen die Heads aufdatiert werden ( --> updatelist ):
      */
      {
	 op = help->number;
	 joblist[OpData[op].job_nr] = 
			      Insert(joblist[OpData[op].job_nr],op); 
	 maschlist[OpData[op].machine_nr] =
			      Insert(maschlist[OpData[op].machine_nr],op);


	 readytime = local_head[op] + OpData[op].process_time;

	 help1 = OpsOfJob[OpData[op].job_nr];
	 while ( help1 != NIL )
	 {
	    if ( num_of_pred[help1->number] >= 0 )
	       if ( local_head[help1->number] <= readytime )
	       {
		  if ( local_head[help1->number] < readytime )
		  {
		     obtained[help1->number] = op;   
		     local_head[help1->number] = readytime;
		     if ( !Member(updatelist, help1->number) )
			updatelist = Insert(updatelist, help1->number);
		  }
		  else
		     obtained[help1->number] = op;
		  
		  /* eine Op mit num_of_succ = 0, hat weder heuristische
		     noch echte Nachfolger; bei einer dieser Op'en endet
		     der krit.Pfad.
		  */
		  num_of_succ[op]++;         
	       }
	       else
		  num_of_succ[op]++;
	    help1 = help1->next;
	 }

	 help1 = OpsOnMachine[OpData[op].machine_nr];
	 while ( help1 != NIL )
	 {
	    if ( num_of_pred[help1->number] >= 0 )
	       if ( local_head[help1->number] <= readytime )
	       {
		  if ( local_head[help1->number] < readytime )
		  {
		     obtained[help1->number] = op;
		     local_head[help1->number] = readytime;
		     if ( !Member(updatelist, help1->number) )
			updatelist = Insert(updatelist, help1->number);
		  }
		  else
		     obtained[help1->number] = op;   

		  /* eine Op mit num_of_succ = 0, hat weder heurist.
		     noch echte Nachfolger; bei einer dieser Op'en endet
		     der krit.Pfad.
		  */
		  num_of_succ[op]++;
	       }
	       else
		  num_of_succ[op]++;
	    help1 = help1->next;
	 }
	 help = help->next;
      }

      cut = Makeempty(cut);


      while ( updatelist != NIL )
      {
	 op = updatelist->number;
	 updatelist = Delete(updatelist, op);
	 readytime = local_head[op] + OpData[op].process_time;
	 help = ConjArcs->succ[op];
	 while ( help != NIL ) 
	 {
	    if ( local_head[help->number] <= readytime ) 
	    {
	       if ( local_head[help->number] < readytime )
	       {
		  obtained[help->number] = op;
		  local_head[help->number] = readytime;
		  if ( !Member( updatelist, help->number ) )
		     updatelist = Insert(updatelist, help->number);
	       }
	       else
		  obtained[help->number] = op;   
	    }
	    help = help->next;
	 }

	 help = DisjArcs->succ[op];
	 while ( help != NIL ) 
	 {
	    if ( local_head[help->number] <= readytime )
	    {
	       if ( local_head[help->number] < readytime )
	       {
		  obtained[help->number] = op;
		  local_head[help->number] = readytime;
		  if ( !Member( updatelist, help->number ) )
		     updatelist = Insert(updatelist, help->number);
	       }
	       else
		  obtained[help->number] = op;   
	    }
	    help = help->next;
	 }
      }
   }

   /* Ermitteln des krit.Pfades:
   */

   /* Op'en, die keine echten bzw. heurist. Nachfolger haben, werden als 
      letzte in die Job- und Maschinenlisten eingereiht;
      Gibt es mehrere, so wird die Op mit der groessten Fertigstellungszeit
      End-Op des krit.Pfades.
   */
   for ( i = 1; i <= NumOfOperations; ++i )
      if ( num_of_succ[i] == 0 )
	cut = Insert(cut, i);


   while ( cut != NIL )
   { 
      op = cut->number;
      help = cut->next;
      while ( help != NIL )
      {
	 if ( local_head[help->number] + OpData[help->number].process_time 
	      >= local_head[op] + OpData[op].process_time )
	    op = help->number;

	 help = help->next;
      }	
      cut = Makeempty(cut);
   }

   pos_path = 1;
   path_critical[pos_path++] = op;

   c_max = OpData[op].process_time;
   while ( obtained[op] != 0 )
   {
      op = obtained[op];
      path_critical[pos_path++] = op;
      c_max = c_max + OpData[op].process_time;
   }

   /* path_critical() enthaelt die Op'en noch in umgekehrter Reihenfolge
      (denn CP wurde vorher mit 'InsertBefore' gefuellt, aber an der restl.
      Prozedur wurde nichts geaendert). Es wird ja bei der letzten Op be-
      gonnen und ueber obtained die erste Op erreicht. Darum muss path_c
      noch einmal andersherum in CriticalPath gelesen werden.
   */
   PathPos = pos_path;

   for ( i = 1; i < PathPos; ++i )
   {
      --pos_path;  
      CriticalPath[i] = path_critical[pos_path];
   }

   /* falls der gefundene Zielfunktionswert die vorlaeufig beste Loesung,
      UpperBound, verbessert, wird diese aufdatiert und die zugehoerige
      Selektion mit Angabe des aktuellen Suchbaumknotens in "output.dat" 
      zur Verfuegung gestellt.
   */
   if ( c_max < UpperBound ){   
      UpperBound = c_max;       
      std::cout << "OBJECTIVE= " << UpperBound << std::endl;
      Set_Solution(maschlist,joblist);
   } 

   
   /* Leeren der Listen: 'zu jedem "malloc" ein "free" !!!`
   */
   for ( i = 0; i <= NumOfJobs; ++i )
      joblist[i] = Makeempty(joblist[i]);
   for ( i = 0; i <= NumOfMachines; ++i )
      maschlist[i] = Makeempty(maschlist[i]);
}
示例#16
0
void BnxChannel::AddMember(const IrcUser &clUser) {
	if (GetMember(clUser.GetNickname()) != MemberEnd())
		return;

	m_vMembers.push_back(Member(clUser));
}
示例#17
0
/** Join cluster of machines where given host is one of them. Join as given role. */
void cluster::join (Role role, remote::Host host) {
	remote::eval (remote::bind (MFUN(_cluster,newMember), Member (remote::thisHost(), role)), host);
}
示例#18
0
Faction::Faction(Character &newLeader)
    :   name("undefined"),
        leader(newLeader)
{
    member.push_back(Member(newLeader, PlayerRank::Leader));
}
示例#19
0
int main() {
    {
        hana::tuple<int> t(2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
    }
    {
        constexpr hana::tuple<int> t(2);
        static_assert(hana::at_c<0>(t) == 2, "");
    }
    {
        constexpr hana::tuple<int> t;
        static_assert(hana::at_c<0>(t) == 0, "");
    }
    {
        constexpr hana::tuple<int, char*> t(2, nullptr);
        static_assert(hana::at_c<0>(t) == 2, "");
        static_assert(hana::at_c<1>(t) == nullptr, "");
    }
    {
        hana::tuple<int, char*> t(2, nullptr);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr);
    }
    {
        hana::tuple<int, char*, std::string> t(2, nullptr, "text");
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "text");
    }
    {
        hana::tuple<int, NoValueCtor, int, int> t(1, NoValueCtor(), 2, 3);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t).id == 1);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3);
    }
    {
        hana::tuple<int, NoValueCtorEmpty, int, int> t(1, NoValueCtorEmpty(), 2, 3);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3);
    }
    {
        struct T { };
        struct U { };
        struct V { };

        constexpr T t{};
        constexpr U u{};
        constexpr V v{};

        constexpr hana::tuple<T> x1{t};             (void)x1;
        constexpr hana::tuple<T, U> x2{t, u};       (void)x2;
        constexpr hana::tuple<T, U, V> x3{t, u, v}; (void)x3;
    }
    {
        struct T { };
        struct U { };
        struct V { };

        // Check for SFINAE-friendliness
        static_assert(!std::is_constructible<
            hana::tuple<T, U>, T
        >{}, "");

        static_assert(!std::is_constructible<
            hana::tuple<T, U>, U, T
        >{}, "");

        static_assert(!std::is_constructible<
            hana::tuple<T, U>, T, U, V
        >{}, "");
    }

    // Make sure we can initialize elements with the brace-init syntax.
    {
        struct Member { };
        struct Element { Member member; };

        hana::tuple<Element, Element> xs{{Member()}, {Member()}};
        hana::tuple<Element, Element> ys = {{Member()}, {Member()}};
        (void)xs; (void)ys;
    }
}
示例#20
0
void Heuristic_Schedule_LB_PREC_RULE()
{

static int selection[MaxNumOfOperations+1], 
		     generate_set[MaxNumOfJobs+1],
	       genpos; 

  struct List  *cut,
	       *help,
	       *updatelist;
  int          minreadytime,
  	       minreadytimemachine,	
	       newminreadytime,
	       selectpos = 1,
	       prior_op,
               low_for_prior_op,
               low_for_op,
	       c_max,
	       pos_path,
	       op, 
	       //j,
	       sum,
	       path_critical[MaxNumOfOperations+1];

   register int i;


  /* cut ist die Liste der einplanbaren Operationen;
     updatelist ist die Menge der Operationen, deren Heads, aufgrund der
     Aenderungen der Heads ihrer Vorgaenger, aufdatiert werden muessen
  */
  cut = updatelist = NIL;


  /* Ermitteln der Vorgaengeranzahl und der Heads pro Operation,
     obtained[i] = j bedeutet: j wird vor i bearbeitet,
  */
  for ( i = 1; i <= NumOfOperations; ++i ) 
  {
     num_of_pred[i] = SonNode->num_of_disj_pred[i] +
                               SonNode->num_of_conj_pred[i];
     local_head[i] = Head[i];
     obtained[i] = 0;
  }


  /* Einmalig: cut initialisieren;
     Im cut werden alle Operationen aufgenommen, die keine echten 
     Vorgaenger besitzen;
     Spaeter wird cut (s. while-Schleife) mit geeigneten Nachfolgern seiner
     Op'en gefuellt.
  */
  for ( i = 1; i <= NumOfOperations; ++i )
  {
	if ( num_of_pred[i] == 0 )
	   cut = Insert(cut, i);
  }

/* ********************** Bestimmung der prior_op ************************** */

  /* Aus dem cut wird die Operation mit der kleinsten Fertigstellungszeit
     (MRT) ermittelt:
     Gibt es mehrere mit derselben Fertigst.zeit, so entscheidet der Tail;
  */
  while ( cut != NIL ) 
  {
     op = cut->number;
     minreadytime = local_head[op] + OpData[op].process_time;
     help = cut->next;
     while ( help != NIL )
     {
	newminreadytime = local_head[help->number] +
                                          OpData[help->number].process_time;
	if ( minreadytime >= newminreadytime ) 
        {
	   if ( minreadytime > newminreadytime ||
		   Tail[op] < Tail[help->number] ) 
           {
	      minreadytime = newminreadytime; 
	      op = help->number;
           }
        }
        help = help->next;
     }

     minreadytimemachine = OpData[op].machine_nr;


     /* generate_set ist die Menge der Operationen aus dem cut, die auf der
	MRTM bearbeitet werden und deren local_head < MRT
     */
     genpos = 1; 
     help = cut;
     while (help != NIL) 
     {
        if (OpData[help->number].machine_nr == minreadytimemachine
                             && local_head[help->number] < minreadytime)
           generate_set[genpos++] = help->number;
        help = help->next;
     }

     /* Besteht das generate_set aus (mind.) 2 Op'en, so wird fuer diese eine
	untere Schranke berechnet;
	die Op mit der kleinsten unteren Schranke wird zur prior_op
     */
     prior_op = generate_set[1];
     if ( genpos > 2 ) 
     {
        low_for_prior_op = LowerBoundCalc_LB_PREC_RULE(minreadytimemachine,
                                        num_of_pred, local_head, prior_op);
        for ( i = 2; i < genpos; ++i )
	{
           low_for_op = LowerBoundCalc_LB_PREC_RULE(minreadytimemachine, num_of_pred,
                                               local_head, generate_set[i]);
           if ( low_for_op < low_for_prior_op )
	   {
              low_for_prior_op = low_for_op;
              prior_op = generate_set[i];
           }
           else 
	   {
              if ( low_for_op == low_for_prior_op &&
                                 Tail[prior_op] < Tail[generate_set[i]] )
              prior_op = generate_set[i];
           }
        }
     }


     /* In selection werden die prior_op's eingetragen; jede Op wird ein-
	mal zur prior_op, so dass am Ende (cut=NIL) in selection eine 
	vollstaendige Selektion steht;

	prior_op wird aus dem cut geloescht;
     */	  
     selection[selectpos++] = prior_op;
     cut = Delete(cut, prior_op);
     num_of_pred[prior_op]--;           

     /* fuer die zuletzt eingefuegte Op kann auf die folgenden Abfragen ver-
	zichtet werden
     */
     if ( selectpos > NumOfJobs * NumOfMachines )
	break;


     /* Zunaechst muessen die local_heads der verbleibenden noch nicht 
	eingeplanten Operationen aufdatiert werden;
	dann:
	Bestimmung geeigneter Operationen, Nachfolger der prior_op, die in 
	den cut aufgenommen werden sollen;  
     */

     sum = local_head[prior_op] + OpData[prior_op].process_time;

     help = OpsOfJob[OpData[prior_op].job_nr];
     while ( help != NIL )
     {
	if (num_of_pred[help->number] >= 0 && local_head[help->number] <= sum) 
	{
	   if ( local_head[help->number] < sum ) 
	   {
	      local_head[help->number] = sum;
	      updatelist = Insert(updatelist, help->number); 
	      obtained[help->number] = prior_op;
	   }
	   else 
	   {
	      obtained[help->number] = prior_op;
	   }
	}
	help = help->next;
     }

     help = OpsOnMachine[OpData[prior_op].machine_nr];  
     while ( help != NIL ) 
     {
	if (num_of_pred[help->number] >= 0 && local_head[help->number] <= sum) 
	{
           if ( local_head[help->number] < sum ) 
           {
              local_head[help->number] = sum;
	      updatelist = Insert(updatelist, help->number);
	      obtained[help->number] = prior_op;
	   }
	   else 
	   {
	      obtained[help->number] = prior_op;
	   }
	}
	help = help->next;
     }


     
     help = ConjArcs->succ[prior_op];
     while ( help != NIL )
     {
	num_of_pred[help->number]--;
	if ( num_of_pred[help->number] == 0 )
	   cut = Insert(cut, help->number);
	help = help->next;
     }
	
     help = DisjArcs->succ[prior_op];  
     while ( help != NIL ) 
     {
        num_of_pred[help->number]--;
        if ( num_of_pred[help->number] == 0 ) 
	   cut = Insert(cut, help->number);
        help = help->next;
     }
     

     /* In updatelist sind die Operationen enthalten, deren local_head auf-
	datiert wurde. Das sind konj.Nachfolger der prior_op und Op'en, die
	auf derselben Maschine wie prior_op bearbeitete werden;
	Die konj. u. disj. Nachfolger dieser Op'en werden in updatelist auf-
	genommen, falls ihr local_head aufdatiert wird.
     */
     while ( updatelist != NIL ) 
     {   
	op = updatelist->number;
	updatelist = Delete(updatelist, op);
	sum = local_head[op] + OpData[op].process_time;
	help = ConjArcs->succ[op];
	while ( help != NIL ) 
	{
           if ( local_head[help->number] <= sum ) 
           {
              if ( local_head[help->number] < sum ) 
              {
                 local_head[help->number] = sum;
		 if ( !Member(updatelist, help->number) )
		    updatelist = Insert(updatelist, help->number);
		 obtained[help->number] = op;
	      }
	      else 
	      {
		 obtained[help->number] = op;
	      }
	   }
	   help = help->next;
	}

	help = DisjArcs->succ[op];
        while ( help != NIL ) 
        {
           if ( local_head[help->number] <= sum ) 
           {
	      if ( local_head[help->number] < sum ) 
              { 
                 local_head[help->number] = sum;
		 if ( !Member(updatelist, help->number) )
		    updatelist = Insert(updatelist, help->number);
		 obtained[help->number] = op;
	      }
	      else 
	      {
		 obtained[help->number] = op;
	      }
	   }
           help = help->next;
        }
     }                                  /* end  while (updatelist != NIL) .. */
  }                                            /* end  while (cut != NIL) .. */


/* ******************** Bestimmung des kritischen Pfades ******************* */

  /* Bestimmung des krit.Pfades - anhand der Selektion und obtained - und des
     Zielfunktionswertes c_max;
  */
  pos_path = 1;
  op = selection[--selectpos];
  path_critical[pos_path++] = op;
  c_max = OpData[op].process_time;
  while ( obtained[op] != 0 ) 
  {    
     op = obtained[op];
     path_critical[pos_path++] = op;
     c_max = c_max + OpData[op].process_time;
  }

  PathPos = pos_path;
  for ( i= 1; i < PathPos; ++i )
  {
     --pos_path;
     CriticalPath[i] = path_critical[pos_path];
  }  

/* **************************       Ausgabe       ************************** */

  /* Verbessert der gefundene Zielfunktionswert die bisher beste Loesung UB,
     -  so wird UB durch c_max aufdatiert,
     -  die Ausgabe aufbereitet: maschlist , joblist
     -  und die Job- u. Maschinenreihenfolgen in output.dat ausgegeben
  */
  if ( c_max < UpperBound ) 
  {
     UpperBound = c_max;       
     std::cout << "OBJECTIVE= " << c_max << std::endl;                            

     /* Die Ausgabelisten maschlist, joblist werden initialisiert:
	  maschlist enthaelt die Job-Reihenfolgen auf den Maschinen,
	  joblist enthaelt die Maschinenreihenfolgen der Jobs
     */	
     for ( i = 0; i <= NumOfMachines; ++i ) 
	maschlist[i] = NIL; 
     for ( i = 0; i <= NumOfJobs; ++i )
	joblist[i] = NIL;

     /* Fuellen der Listen
     */
     for ( i = 1; i <= NumOfOperations; ++i ) 
	maschlist[ OpData[selection[i]].machine_nr ] =
	  Insert(maschlist[OpData[selection[i]].machine_nr], selection[i]);
     for ( i = 1; i <= NumOfOperations; ++i ) 
	joblist[ OpData[selection[i]].job_nr ] =
	  Insert(joblist[OpData[selection[i]].job_nr], selection[i]);

    Set_Solution(maschlist,joblist);

  }
}
示例#21
0
 void addMember(const std::string& name,size_t offset)
 {
   if(!isInSubset(name))return;
   VSOctaveH5InternalType t = VSOctaveH5CompositeMemberType<T>::int_type();
   m_members.push_back(Member(m_prefix+name, t, offset));
 }
示例#22
0
 SafeMemberPerson(unsigned int age) :
   member(Member(age))
 {  }
示例#23
0
文件: Grib.cpp 项目: WFRT/Comps
void InputGrib::getMembersCore(std::vector<Member>& iMembers) const {
   iMembers.push_back(Member(getName(), 0, "", 0));
}
示例#24
0
文件: struct.c 项目: cc65/cc65
static long DoStructInternal (long Offs, unsigned Type)
/* Handle the .STRUCT command */
{
    long Size = 0;

    /* Outside of other structs, we need a name. Inside another struct or
    ** union, the struct may be anonymous, in which case no new lexical level
    ** is started.
    */
    int Anon = (CurTok.Tok != TOK_IDENT);
    if (!Anon) {
        /* Enter a new scope, then skip the name */
        SymEnterLevel (&CurTok.SVal, SCOPE_STRUCT, ADDR_SIZE_ABS, 0);
        NextTok ();
        /* Start at zero offset in the new scope */
        Offs = 0;
    }

    /* Test for end of line */
    ConsumeSep ();

    /* Read until end of struct */
    while (CurTok.Tok != TOK_ENDSTRUCT &&
           CurTok.Tok != TOK_ENDUNION  &&
           CurTok.Tok != TOK_EOF) {

        long      MemberSize;
        SymTable* Struct;
        SymEntry* Sym;

        /* Allow empty and comment lines */
        if (CurTok.Tok == TOK_SEP) {
            NextTok ();
            continue;
        }

        /* The format is "[identifier] storage-allocator [, multiplicator]" */
        Sym = 0;
        if (CurTok.Tok == TOK_IDENT) {

            /* Beware: An identifier may also be a macro, in which case we have
            ** to start over.
            */
            Macro* M = FindMacro (&CurTok.SVal);
            if (M) {
                MacExpandStart (M);
                continue;
            }

            /* We have an identifier, generate a symbol */
            Sym = SymFind (CurrentScope, &CurTok.SVal, SYM_ALLOC_NEW);

            /* Assign the symbol the offset of the current member */
            SymDef (Sym, GenLiteralExpr (Offs), ADDR_SIZE_DEFAULT, SF_NONE);

            /* Skip the member name */
            NextTok ();
        }

        /* Read storage allocators */
        MemberSize = 0;                 /* In case of errors, use zero */
        switch (CurTok.Tok) {

            case TOK_BYTE:
                NextTok ();
                MemberSize = Member (1);
                break;

            case TOK_DBYT:
            case TOK_WORD:
            case TOK_ADDR:
                NextTok ();
                MemberSize = Member (2);
                break;

            case TOK_FARADDR:
                NextTok ();
                MemberSize = Member (3);
                break;

            case TOK_DWORD:
                NextTok ();
                MemberSize = Member (4);
                break;

            case TOK_RES:
                NextTok ();
                if (CurTok.Tok == TOK_SEP) {
                    ErrorSkip ("Size is missing");
                } else {
                    MemberSize = Member (1);
                }
                break;

            case TOK_TAG:
                NextTok ();
                Struct = ParseScopedSymTable ();
                if (Struct == 0) {
                    ErrorSkip ("Unknown struct/union");
                } else if (GetSymTabType (Struct) != SCOPE_STRUCT) {
                    ErrorSkip ("Not a struct/union");
                } else {
                    SymEntry* SizeSym = GetSizeOfScope (Struct);
                    if (!SymIsDef (SizeSym) || !SymIsConst (SizeSym, &MemberSize)) {
                        ErrorSkip ("Size of struct/union is unknown");
                    }
                }
                MemberSize = Member (MemberSize);
                break;

            case TOK_STRUCT:
                NextTok ();
                MemberSize = DoStructInternal (Offs, STRUCT);
                break;

            case TOK_UNION:
                NextTok ();
                MemberSize = DoStructInternal (Offs, UNION);
                break;

            default:
                if (!CheckConditionals ()) {
                    /* Not a conditional directive */
                    ErrorSkip ("Invalid storage allocator in struct/union");
                }
        }

        /* Assign the size to the member if it has a name */
        if (Sym) {
            DefSizeOfSymbol (Sym, MemberSize);
        }

        /* Next member */
        if (Type == STRUCT) {
            /* Struct */
            Offs += MemberSize;
            Size += MemberSize;
        } else {
            /* Union */
            if (MemberSize > Size) {
                Size = MemberSize;
            }
        }

        /* Expect end of line */
        ConsumeSep ();
    }

    /* If this is not a anon struct, enter a special symbol named ".size"
    ** into the symbol table of the struct that holds the size of the
    ** struct. Since the symbol starts with a dot, it cannot be accessed
    ** by user code.
    ** Leave the struct scope level.
    */
    if (!Anon) {
        /* Add a symbol */
        SymEntry* SizeSym = GetSizeOfScope (CurrentScope);
        SymDef (SizeSym, GenLiteralExpr (Size), ADDR_SIZE_DEFAULT, SF_NONE);

        /* Close the struct scope */
        SymLeaveLevel ();
    }

    /* End of struct/union definition */
    if (Type == STRUCT) {
        Consume (TOK_ENDSTRUCT, "'.ENDSTRUCT' expected");
    } else {
        Consume (TOK_ENDUNION, "'.ENDUNION' expected");
    }

    /* Return the size of the struct */
    return Size;
}
示例#25
0
void Heuristic_Schedule_BOTTLE_MATCHING()

{
   struct List *cut,                             /* Op'en e-s Matchings */
	       *updatelist,	                 /* local_heads aufdatieren*/
	       *help,
	       *help1;      
   int         i, 
	       j,
	       k,
	       readytime,                         /* Fertigstellungszeit    */
	       c_max,
	       sum,
	       //prior_op,                          /* Op'en fuer CriticalPath*/
	       op,
	       iter,                              /* zaehlt betrachtete Open*/
               pos_path,
               path_critical[MaxNumOfOperations+1];


   cut = updatelist = NIL;

   for ( i = 0; i <= NumOfJobs; ++i )
      joblist[i] = NIL;
   for ( i = 0; i <= NumOfMachines; ++ i )
      maschlist[i] = NIL;

   iter = 0;

   for ( i = 1; i <= NumOfOperations; ++i )
   {
      num_of_pred[i] = SonNode->num_of_conj_pred[i] +
		       SonNode->num_of_disj_pred[i];
      num_of_succ[i] = SonNode->num_of_conj_succ[i] +
		       SonNode->num_of_disj_succ[i];
      local_head[i] = Head[i];
      obtained[i] = 0;
   }

   /* Besonderheit: BottleMatch ist so implementiert, dass die erste Maschine
      bei NumOfJobs+1 beginnt (z.B.:2 Jobs, 3 Maschinen --> 1,2 fuer Jobs,
      3,4,5 fuer Maschinen);
      wird spaeter wieder rueckgaengig gemacht, wenn die Zuordnung berechnet
      ist (s.u. j = mate[i])
   */

   /* Diese while-Schleife bricht ab, wenn alle Op'en betrachtet wurden
      ( iter = NumOfOperations ). Jedesmal, wenn eine Op in cut eingefuegt 
      wird, wird iter um eins erhoeht.
   */
   while ( iter < NumOfOperations )
   {
      /* Einlesen der Zeitmatrix :
	 Op'en, mit num_of_pred <> 0 muessen fuers Matching ausgeschlossen
	 werden;
      */
      sum = 1;
      for ( i = 0; i < NumOfOperations; ++i )
      {
	 /* hier:
	    Kantengewichte = pos. Bearbeitungszeiten, falls num_of_pred = 0,
	 */
	 if ( num_of_pred[sum] == 0 )
	 {
	    A[i].s = OpData[sum].job_nr;
	    A[i].t = OpData[sum].machine_nr + NumOfJobs;
	    A[i].weight = minmax_match*(OpData[sum].process_time+head_match*Head[sum]);
	    sum++;
	 }
	 else
	 {
	    sum++;
	    --i;
	 }
      }



      /* Loesen des Matchingproblems
      */
      BottleMatch_BOTTLE_MATCH(NumOfJobs, NumOfMachines, NumOfOperations, A);
      for ( i = 1; i <= NumOfJobs; i++ )
      {
	 if ( mate[i] != 0 )
	 {
	    j = mate[i];
	    /* (s.o "Rueckgaengigmachen") Maschinennummer fuer Maschine n 
	       ist wieder n
	    */
	    k = j - NumOfJobs;
	    op = FindOpNr(i,k);

	    if ( num_of_pred[op] == 0 )
	    {
	       cut = Insert(cut,op);

	       /* Op'en des Matchings werden fuer's folgende ausgeschlossen
	       */
	       num_of_pred[op]--;
	       iter++;

	       /* konj./disj. Nachfolger der Op'en des Matchings werden fuer 
		  folgendes zugelassen, wenn die Anzahl ihrer Vorgaenger auf
		  Null reduziert wird.
	       */
	       help = ConjArcs->succ[op];
	       while ( help != NIL )
	       {
		  num_of_pred[help->number]--;
		  help = help->next;
	       }

	       help = DisjArcs->succ[op];
	       while ( help != NIL )
	       {
		  num_of_pred[help->number]--;
		  help = help->next;
	       }
	    }
	 }
      }

      help = cut;
      while ( help != NIL )
      /* 1. Die Op'en des cut werden in die Job- u. Maschinenreihenfolgen
	    eingereiht.
	 2. Aufdatieren:
	    bei Op'en, die nach den Op'en des Matchings bearbeitet werden,
	    muessen die Heads aufdatiert werden ( --> updatelist ):
      */
      {
	 op = help->number;
	 joblist[OpData[op].job_nr] = 
			      Insert(joblist[OpData[op].job_nr],op); 
	 maschlist[OpData[op].machine_nr] =
			      Insert(maschlist[OpData[op].machine_nr],op);


	 readytime = local_head[op] + OpData[op].process_time;

	 help1 = OpsOfJob[OpData[op].job_nr];
	 while ( help1 != NIL )
	 {
	    if ( num_of_pred[help1->number] >= 0 )
	       if ( local_head[help1->number] <= readytime )
	       {
		  if ( local_head[help1->number] < readytime )
		  {
		     obtained[help1->number] = op;   
		     local_head[help1->number] = readytime;
		     if ( !Member(updatelist, help1->number) )
			updatelist = Insert(updatelist, help1->number);
		  }
		  else
		     obtained[help1->number] = op;
		  
		  /* eine Op mit num_of_succ = 0, hat weder heuristische
		     noch echte Nachfolger; bei einer dieser Op'en endet
		     der krit.Pfad.
		  */
		  num_of_succ[op]++;         
	       }
	       else
		  num_of_succ[op]++;
	    help1 = help1->next;
	 }

	 help1 = OpsOnMachine[OpData[op].machine_nr];
	 while ( help1 != NIL )
	 {
	    if ( num_of_pred[help1->number] >= 0 )
	       if ( local_head[help1->number] <= readytime )
	       {
		  if ( local_head[help1->number] < readytime )
		  {
		     obtained[help1->number] = op;
		     local_head[help1->number] = readytime;
		     if ( !Member(updatelist, help1->number) )
			updatelist = Insert(updatelist, help1->number);
		  }
		  else
		     obtained[help1->number] = op;   

		  /* eine Op mit num_of_succ = 0, hat weder heuristische
		     noch echte Nachfolger; bei einer dieser Op'en endet
		     der krit.Pfad.
		  */
		  num_of_succ[op]++;
	       }
	       else
		  num_of_succ[op]++;
	    help1 = help1->next;
	 }
	 help = help->next;
      }

      cut = Makeempty(cut);


      while ( updatelist != NIL )
      {
	 op = updatelist->number;
	 updatelist = Delete(updatelist, op);
	 readytime = local_head[op] + OpData[op].process_time;
	 help = ConjArcs->succ[op];
	 while ( help != NIL ) 
	 {
	    if ( local_head[help->number] <= readytime ) 
	    {
	       if ( local_head[help->number] < readytime )
	       {
		  obtained[help->number] = op;
		  local_head[help->number] = readytime;
		  if ( !Member( updatelist, help->number ) )
		     updatelist = Insert(updatelist, help->number);
	       }
	       else
		  obtained[help->number] = op;   
	    }
	    help = help->next;
	 }

	 help = DisjArcs->succ[op];
	 while ( help != NIL ) 
	 {
	    if ( local_head[help->number] <= readytime )
	    {
	       if ( local_head[help->number] < readytime )
	       {
		  obtained[help->number] = op;
		  local_head[help->number] = readytime;
		  if ( !Member( updatelist, help->number ) )
		     updatelist = Insert(updatelist, help->number);
	       }
	       else
		  obtained[help->number] = op;   
	    }
	    help = help->next;
	 }
      }
   }

   /* Ermitteln des krit.Pfades:
   */

   /* Op'en, die keine echten bzw. heurist. Nachfolger haben, werden als 
      letzte in die Job- und Maschinenlisten eingereiht;
      Gibt es mehrere, so wird die Op mit dem groessten Fertigstellungszeit
      End-Op des krit.Pfades.
   */
   for ( i = 1; i <= NumOfOperations; ++i )
      if ( num_of_succ[i] == 0 )
	cut = Insert(cut, i);


   while ( cut != NIL )
   { 
      op = cut->number;
      help = cut->next;
      while ( help != NIL )
      {
	 if ( local_head[help->number] + OpData[help->number].process_time 
	      >= local_head[op] + OpData[op].process_time )
	    op = help->number;

	 help = help->next;
      }	
      cut = Makeempty(cut);
   }

   pos_path = 1;
   path_critical[pos_path++] = op;

   c_max = OpData[op].process_time;
   while ( obtained[op] != 0 )
   {
      op = obtained[op];
      path_critical[pos_path++] = op;
      c_max = c_max + OpData[op].process_time;
   }

   /* path_critical() enthaelt die Op'en noch in umgekehrter Reihenfolge
      (denn CP wurde vorher mit 'InsertBefore' gefuellt, aber an der restl.
      Prozedur wurde nichts geaendert). Es wird ja bei der letzten Op be-
      gonnen und ueber obtained die erste Op erreicht. Darum muss path_c
      noch einmal andersherum in CriticalPath gelesen werden.
   */

   PathPos = pos_path;

   for ( i = 1; i < PathPos; ++i )
   {
      --pos_path;  
      CriticalPath[i] = path_critical[pos_path];
   }

   /* falls der gefundene Zielfunktionswert die vorlaeufig beste Loesung,
      UpperBound, verbessert, wird diese aufdatiert und die zugehoerige
      Selektion mit Angabe des aktuellen Suchbaumknotens in "output.dat" 
      zur Verfuegung gestellt.
   */
      
   if ( c_max < UpperBound )
   {   
      UpperBound = c_max;
      std::cout << "OBJECTIVE= " << UpperBound << std::endl;
      Set_Solution(maschlist,joblist);
   } 

   /* Leeren der Listen: 'zu jedem "malloc" ein "free" !!!`
   */
   for ( i = 0; i <= NumOfJobs; ++i )
      joblist[i] = Makeempty(joblist[i]);
   for ( i = 0; i <= NumOfMachines; ++i )
      maschlist[i] = Makeempty(maschlist[i]);
}
示例#26
0
int EnsembleIn_Single::ReadEnsemble(int currentFrame, FrameArray& f_ensemble,
                                  FramePtrArray& f_sorted )
{
  badEnsemble_ = false;
  // Read in all replicas.
  if ( eio_->readArray( currentFrame, f_ensemble ) ) return 1;
# ifdef MPI
  int ensembleFrameNum = 0;
  if (targetType_ != ReplicaInfo::NONE) {
    int my_idx;
    if (targetType_ == ReplicaInfo::TEMP)
      my_idx = TemperatureMap_.FindIndex( f_ensemble[0].Temperature() );
    else if (targetType_ == ReplicaInfo::INDICES)
      my_idx = IndicesMap_.FindIndex( f_ensemble[0].RemdIndices() );
#   ifdef TIMER
    mpi_allgather_timer_.Start();
#   endif
    // TODO: Put this in Traj_NcEnsemble
    if (EnsembleComm().AllGather( &my_idx, 1, MPI_INT, &frameidx_[0])) {
      rprinterr("Error: Gathering frame indices.\n");
      badEnsemble_ = true;
      return 0; // TODO: Better parallel error check
    }
    for (int i = 0; i != ensembleSize_; i++)
      if (frameidx_[i] == -1) {
        badEnsemble_ = true;
        break;
      }
#   ifdef TIMER
    mpi_allgather_timer_.Stop();
    mpi_sendrecv_timer_.Start();
#   endif
    if (!badEnsemble_) {
      for (int sendrank = 0; sendrank != ensembleSize_; sendrank++) {
        int recvrank = frameidx_[sendrank];
        if (sendrank != recvrank) {
          if (sendrank == Member())
            f_ensemble[0].SendFrame( recvrank, EnsembleComm() );
          else if (recvrank == Member()) {
            f_ensemble[1].RecvFrame( sendrank, EnsembleComm() );
            // Since a frame was received, indicate position 1 should be used
            ensembleFrameNum = 1;
          }
        }
        //else rprintf("SEND RANK == RECV RANK, NO COMM\n"); // DEBUG
      }
    }
#   ifdef TIMER
    mpi_sendrecv_timer_.Stop();
#   endif
  }
  f_sorted[0] = &f_ensemble[ensembleFrameNum];
# else
  int fidx;
  for (int i = 0; i != ensembleSize_; i++) {
    if (targetType_ == ReplicaInfo::TEMP)
      fidx = TemperatureMap_.FindIndex( f_ensemble[i].Temperature() );
    else if (targetType_ == ReplicaInfo::INDICES)
      fidx = IndicesMap_.FindIndex( f_ensemble[i].RemdIndices() );
    else // NONE
      fidx = i;
    if ( fidx == -1 )
      badEnsemble_ = true;
    else
      f_sorted[fidx] = &f_ensemble[i];
  }
# endif
  return 0;
}