Example #1
0
void RRSchedule::print_TripleVector(TripleVector _invect, std::ostream &stream = std::cout)
{
    for (TripleVector::const_iterator row = _invect.begin(); row != _invect.end(); ++row)
    {
        print_DoubleVector(*row, stream);
        stream << '\n' << std::flush;
    }
}
Example #2
0
void RRSchedule::allocate3D(TripleVector & _invect, int row, int col, int depth)
{
    _invect.clear();
    _invect.reserve(row);
    for (int i = 0; i < row; i++)
    {
        allocate2D(_invect[i], col, depth);
    }
}
Example #3
0
  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));
  }
Example #4
0
  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);
  }
Example #5
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;
    
}
Qwt3D::ParallelEpiped Qwt3D::hull(TripleVector const& data)
{
  ParallelEpiped hull(Triple(DBL_MAX,DBL_MAX,DBL_MAX),Triple(-DBL_MAX,-DBL_MAX,-DBL_MAX));
  for (unsigned i = 0; i!=data.size(); ++i)
	{
		if (data[i].x < hull.minVertex.x)
			hull.minVertex.x = data[i].x;
		if (data[i].y < hull.minVertex.y)
			hull.minVertex.y = data[i].y;
		if (data[i].z < hull.minVertex.z)
			hull.minVertex.z = data[i].z;
		
		if (data[i].x > hull.maxVertex.x)
			hull.maxVertex.x = data[i].x;
		if (data[i].y > hull.maxVertex.y)
			hull.maxVertex.y = data[i].y;
		if (data[i].z > hull.maxVertex.z)
			hull.maxVertex.z = data[i].z;
	}
  return hull;
}