Skip to content

Commit

Permalink
Check lesson order only for groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
olegshtch committed May 24, 2011
1 parent 316cdf7 commit 130c0f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/ga/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,27 @@ GraphForTime::GraphForTime()
}

m_Links.resize(m_Items.size());
m_LinksGroup.resize(m_Items.size());
size_t row;
for(row = 0; row < m_Items.size(); ++ row)
{
m_Links[row].resize(m_Items.size());
m_LinksGroup[row].resize(m_Items.size());
}
for(row = 0; row < m_Items.size(); ++ row)
{
for(size_t col = row + 1; col < m_Items.size(); ++ col)
{
const bool link = (m_Items[row].t == m_Items[col].t) || (m_Items[row].l == m_Items[col].l) || db.InterseptGroups(m_Items[row].l, m_Items[col].l);
const bool link_group = db.InterseptGroups(m_Items[row].l, m_Items[col].l);
const bool link = (m_Items[row].t == m_Items[col].t) || (m_Items[row].l == m_Items[col].l) || link_group;
/*if(link)
{
std::cout << "link row=" << row << " col=" << col << std::endl;
}*/
m_Links[row][col] = link;
m_Links[col][row] = link;
m_LinksGroup[row][col] = link_group;
m_LinksGroup[col][row] = link_group;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/ga/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class GraphForTime
{
return m_Links;
}
const std::vector<std::vector<char> >& LinksGroup() const
{
return m_LinksGroup;
}
const std::vector<ItemColor>& Colors() const
{
return m_Colors;
Expand All @@ -87,6 +91,7 @@ class GraphForTime
private:
std::vector<ItemTLBM> m_Items;
std::vector<std::vector<char> > m_Links;
std::vector<std::vector<char> > m_LinksGroup;
std::vector<ItemColor> m_Colors;
std::vector<long int> m_MultiAuds;
std::vector<long int> m_SingleAuds;
Expand Down
3 changes: 2 additions & 1 deletion src/ga/individual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ long Individual::FitnessCalculate() const
{
for(size_t j = 0; j < m_Graph.Items().size(); ++ j) //индекс другого занятия
{
if((m_Coloring[j].color > 0)
if(m_Graph.LinksGroup()[i][j]
&& (m_Coloring[j].color > 0)
&& (m_Coloring[i].color < m_Coloring[j].color)
&& (m_Graph.Items()[i].b == m_Graph.Items()[j].b)
&& (m_Graph.Items()[i].lt > m_Graph.Items()[j].lt))
Expand Down

0 comments on commit 130c0f4

Please sign in to comment.