コード例 #1
0
ファイル: graph.cpp プロジェクト: gcoco/qwtplot3d
  void Plot::createCube(double length, const Triple& shift)
  {
    
    unsigned m = nodes.size();
    nodes.push_back(Triple(0,0,0)+shift);
    nodes.push_back(Triple(0,0,length)+shift);
    nodes.push_back(Triple(0,length,length)+shift);
    nodes.push_back(Triple(0,length,0)+shift);
    nodes.push_back(Triple(length,0,0)+shift);
    nodes.push_back(Triple(length,0,length)+shift);
    nodes.push_back(Triple(length,length,length)+shift);
    nodes.push_back(Triple(length,length,0)+shift);

    edges.push_back(Edge(m+0, m+1));
    edges.push_back(Edge(m+1, m+2));
    edges.push_back(Edge(m+2, m+3));
    edges.push_back(Edge(m+3, m+0));

    unsigned n = 4; 

    edges.push_back(Edge(m+0+n, m+1+n));
    edges.push_back(Edge(m+1+n, m+2+n));
    edges.push_back(Edge(m+2+n, m+3+n));
    edges.push_back(Edge(m+3+n, m+0+n));

    edges.push_back(Edge(m+0, m+0+n));
    edges.push_back(Edge(m+1, m+1+n));
    edges.push_back(Edge(m+2, m+2+n));
    edges.push_back(Edge(m+3, m+3+n));
  }
コード例 #2
0
bool RRSchedule::sort_times_new(DoubleVector &_week)
{
    int minScore = max_teams * 100 * max_times;
    int score;
    Vector team_waits_now;
    DoubleVector bestWeek;
    Vector bestWaits;
    TripleVector potentialWeeks;
    
    //print_DoubleVector(_week);
    
    // Loop through all permutations of timeslots
    for (DoubleVector::const_iterator permute = timePermutes.begin(); permute != timePermutes.end(); ++permute)
    {
        DoubleVector testWeek = reconfigureWeek(_week, *permute);
        
        // Score the week based on total team waiting time
        score = compute_week_fitness(testWeek);
        
        // If the score is an improvement, keep that permutation
        if (score < minScore)
        {
            potentialWeeks.clear();
            potentialWeeks.push_back(testWeek);
            //bestWeek = testWeek;
            minScore = score;
            //std::cout << "Week Score (Sorted): " << score << std::endl;
        }
        else if (score == minScore)
        {
            potentialWeeks.push_back(testWeek);
        }
    }
    
    int randSelect = rand() % potentialWeeks.size();
    bestWeek = potentialWeeks[randSelect];
    
    //std::cout << "Random Selection: " << potentialWeeks.size() << "," << randSelect << std::endl;
    
    // Ugh, sorry; Hard overwrite the timeslots with the best version of the week
    timeslots = bestWeek;
    return true;
    
}
コード例 #3
0
ファイル: graph.cpp プロジェクト: gcoco/qwtplot3d
  void Plot::createCubic2()
  {
    unsigned xs = 2;
    unsigned ys = xs;
    unsigned zs = xs;

    unsigned i,j,k;
    for (i=0; i!=xs; ++i)
      for (j=0; j!=ys; ++j)
        for (k=0; k!=zs; ++k)
          nodes.push_back(Triple(i,j,k));

    for (i=0; i!=nodes.size()-1; ++i)
    {
      edges.push_back(Edge(i,i+1));
    } 
    createDataset(nodes, edges);
  }