Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Emmanuel Hebrard
SchedCL
Commits
47873d28
Commit
47873d28
authored
Mar 03, 2022
by
ehebrard
Browse files
debug
parent
d0058123
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cpp/Graph.cpp
View file @
47873d28
...
...
@@ -371,39 +371,30 @@ ostream &Graph::display(ostream &os) const {
for
(
auto
i
{
0
};
i
<
size
();
++
i
)
{
os
<<
setw
(
3
)
<<
i
<<
":"
;
// if (not vertices.has(i)) {
// os << endl;
// } else {
int
k
{
0
};
#ifdef DEBUG_SG
int
k
=
0
;
#endif
for
(
auto
v
:
neighbor
[
OUT
][
i
])
{
os
<<
" "
<<
v
#ifdef DEBUG_SG
<<
"@"
<<
neighbor_rank
[
OUT
][
i
][
k
++
]
#endif
;
// assert(edges.has(i,v));
}
os
<<
" /"
;
#ifdef DEBUG_SG
k
=
0
;
#endif
for
(
auto
v
:
neighbor
[
IN
][
i
])
{
os
<<
" "
<<
v
#ifdef DEBUG_SG
<<
"@"
<<
neighbor_rank
[
IN
][
i
][
k
++
]
#endif
;
// assert(edges.has(v,i));
}
os
<<
endl
;
// }
}
// os << edges << endl;
return
os
;
}
...
...
src/header/ConstraintGraph.hpp
View file @
47873d28
...
...
@@ -42,8 +42,10 @@ public:
size_t
size
()
const
;
size_t
numVar
()
const
;
size_t
numCon
()
const
;
//
// int var(const int i) const;
ostream
&
display
(
ostream
&
os
)
const
;
ostream
&
display
(
ostream
&
os
)
const
;
};
...
...
@@ -52,7 +54,7 @@ ConstraintGraph<T>::ConstraintGraph() {}
template
<
typename
T
>
const
vector
<
int
>
&
ConstraintGraph
<
T
>::
operator
[](
const
int
var_id
)
const
{
return
network
[
var_id
+
numCon
()
];
return
network
[
var_id
];
}
// template<typename T>
...
...
@@ -60,6 +62,11 @@ const vector<int> &ConstraintGraph<T>::operator[](const int var_id) const {
// return network[PREDECESSOR][cons_id];
// }
// template<typename T>
// int ConstraintGraph<T>::var(const int i) const {
// return i + numCon();
// }
template
<
typename
T
>
size_t
ConstraintGraph
<
T
>::
size
()
const
{
return
network
.
size
();
...
...
@@ -79,7 +86,7 @@ size_t ConstraintGraph<T>::numVar() const {
template
<
typename
T
>
int
ConstraintGraph
<
T
>::
addVar
()
{
network
.
resize
(
size
()
+
1
);
return
static_cast
<
int
>
(
numVar
())
-
1
;
return
static_cast
<
int
>
(
size
())
-
1
;
}
// add a new constraint
...
...
src/header/ConstraintQueue.hpp
View file @
47873d28
...
...
@@ -70,6 +70,10 @@ void ConstraintQueue<T, N>::initialize(vector<ResourceConstraint<T>*> *c) {
template
<
typename
T
,
int
N
>
void
ConstraintQueue
<
T
,
N
>::
triggers
(
const
int
var_id
,
const
int
cons_id
)
{
assert
(
cons_id
>=
0
);
assert
(
cons_id
<
constraints
->
size
());
auto
cons
=
(
*
constraints
)[
cons_id
];
cons
->
notify
(
var_id
);
...
...
src/header/Scheduler.hpp
View file @
47873d28
...
...
@@ -200,6 +200,8 @@ public:
ostream
&
display
(
ostream
&
os
)
const
;
ostream
&
displayStats
(
ostream
&
os
)
const
;
ostream
&
displayNetwork
(
ostream
&
os
)
const
;
ostream
&
displayChoicePoint
(
ostream
&
os
,
const
DistanceConstraint
<
T
>
&
cp
)
const
;
...
...
@@ -269,24 +271,28 @@ template <typename T>
void
Scheduler
<
T
>::
wake_me_on
(
const
event
x
,
const
event
y
,
const
int
c
,
const
bool
choicepoint
)
{
cout
<<
"wake "
<<
c
<<
" on "
<<
x
<<
"/"
<<
y
<<
" ("
<<
choicepoint
<<
")"
<<
endl
;
auto
rx
{
distance
.
getRepresentant
(
x
)};
auto
ry
{
distance
.
getRepresentant
(
y
)};
// cout << "wake " << c << " on "<< x << "/" << y << " (" << choicepoint <<
// ")\n";
if
(
getVariable
(
rx
,
ry
)
==
NoVar
)
{
cout
<<
"declare var "
<<
rx
<<
"/"
<<
ry
<<
" ("
<<
choicepoint
<<
")"
<<
endl
;
declareVariable
(
rx
,
ry
);
// this is a variable that a constraint wants in its watch list
// cout << "declare var " << rx << "/" << ry << " (" << choicepoint <<
// ")\n";
if
(
choicepoint
)
{
// TODO: may not always be 0, but tricky
choicepoints
.
push_back
({
rx
,
ry
,
0
});
}
}
cout
<<
"create triggers"
<<
endl
;
if
(
network
[
varmap
[
rx
][
ry
]].
empty
()
or
network
[
varmap
[
rx
][
ry
]].
back
()
!=
c
)
network
.
createTrigger
(
varmap
[
rx
][
ry
],
c
);
...
...
@@ -539,13 +545,13 @@ template <typename T> void Scheduler<T>::initialize() {
for
(
auto
i
{
0
};
i
<
network
.
numCon
();
++
i
)
{
//
cout << "post " << *(network.constraints[i]) << endl;
cout
<<
"post "
<<
*
(
network
.
constraints
[
i
])
<<
endl
;
network
.
constraints
[
i
]
->
post
(
i
);
}
//
cout << network.numVar() << " variables, " << network.numCon()
//
<< " constraints\n";
cout
<<
network
.
numVar
()
<<
" variables, "
<<
network
.
numCon
()
<<
" constraints
\n
"
;
queue
.
initialize
(
&
network
.
constraints
);
...
...
@@ -560,6 +566,12 @@ template <typename T> void Scheduler<T>::initialize() {
// initialisation
sequence
.
reserve
(
choicepoints
.
size
());
sequence
.
fill
();
cout
<<
endl
<<
"INIT:
\n
"
;
displayNetwork
(
cout
);
cout
<<
endl
;
}
template
<
typename
T
>
void
Scheduler
<
T
>::
search
()
{
...
...
@@ -733,6 +745,13 @@ template <typename T> void Scheduler<T>::backtrack() {
template
<
typename
T
>
void
Scheduler
<
T
>::
updateNetwork
(
vector
<
event
>::
const_iterator
first
)
{
if
(
first
!=
distance
.
firstActive
())
{
cout
<<
endl
;
displayNetwork
(
cout
);
cout
<<
endl
;
}
for
(
auto
merged
{
first
};
merged
!=
distance
.
firstActive
();
++
merged
)
{
auto
merged_event
{
*
merged
};
auto
rep_event
{
distance
.
getRepresentant
(
merged_event
)};
...
...
@@ -762,8 +781,15 @@ void Scheduler<T>::updateNetwork(vector<event>::const_iterator first) {
}
}
#endif
if
(
rep_event
!=
rep_other
)
if
(
rep_event
!=
rep_other
)
{
cout
<<
endl
;
displayNetwork
(
cout
);
cout
<<
endl
;
network
.
merge
(
the_rep
,
to_merge
);
cout
<<
" -->"
<<
endl
;
displayNetwork
(
cout
);
cout
<<
endl
;
}
}
to_merge
=
getVariable
(
other_event
,
merged_event
);
...
...
@@ -785,8 +811,15 @@ void Scheduler<T>::updateNetwork(vector<event>::const_iterator first) {
}
#endif
if
(
rep_event
!=
rep_other
)
if
(
rep_event
!=
rep_other
)
{
cout
<<
endl
;
displayNetwork
(
cout
);
cout
<<
endl
;
network
.
merge
(
the_rep
,
to_merge
);
cout
<<
" -->"
<<
endl
;
displayNetwork
(
cout
);
cout
<<
endl
;
}
}
}
#ifdef DEBUG_MERGE
...
...
@@ -1402,6 +1435,28 @@ Scheduler<T>::displayChoicePoint(ostream &os,
// }
// #endif
template
<
typename
T
>
ostream
&
Scheduler
<
T
>::
displayNetwork
(
ostream
&
os
)
const
{
for
(
auto
i
{
0
};
i
<
numEvent
();
++
i
)
{
if
(
distance
.
isActive
(
i
))
{
for
(
auto
j
{
0
};
j
<
numEvent
();
++
j
)
{
if
(
distance
.
isActive
(
j
))
{
auto
xij
{
varmap
[
i
][
j
]};
if
(
xij
!=
NoVar
)
{
os
<<
xij
<<
" ("
<<
label
(
i
)
<<
","
<<
label
(
j
)
<<
"):"
;
for
(
auto
c
:
network
[
xij
])
os
<<
" "
<<
*
(
network
.
constraints
[
c
]);
// os << " c" << c;
os
<<
endl
;
}
}
}
}
}
return
os
;
}
template
<
typename
T
>
ostream
&
Scheduler
<
T
>::
display
(
ostream
&
os
)
const
{
auto
pwidth
{
distance
.
getPrintWidth
()};
auto
lwidth
=
(
int
)(
std
::
log
(
numEvent
())
/
std
::
log
(
10
));
...
...
@@ -1419,21 +1474,8 @@ template <typename T> ostream &Scheduler<T>::display(ostream &os) const {
os
<<
endl
;
}
// for (auto i{0}; i < numEvent(); ++i) {
// if (distance.isActive(i)) {
// for (auto j{0}; j < numEvent(); ++j) {
// if (distance.isActive(j)) {
// auto xij{varmap[i][j]};
// if (xij != NoVar) {
// cout << label(i) << "->" << label(j) << ":";
// for (auto c : network[xij])
// cout << " " << *(network.constraints[c]);
// cout << endl;
// }
// }
// }
// }
// }
// displayNetwork(os);
// os << endl;
// os << network << endl;
...
...
src/header/TimeTabling.hpp
View file @
47873d28
...
...
@@ -152,11 +152,24 @@ void CumulativeTimeTabling<T, C>::post(const int idx) {
cout
<<
"post "
<<
*
this
<<
endl
;
}
#endif
cout
<<
"post "
<<
*
this
<<
endl
;
// int k{0};
for
(
int
i
{
0
};
i
<
m_tasks
.
size
();
++
i
)
{
cout
<<
i
<<
endl
;
cout
<<
m_tasks
[
i
]
<<
endl
;
cout
<<
START
(
m_tasks
[
i
])
<<
endl
;
m_schedule
.
wake_me_on
(
START
(
m_tasks
[
i
]),
ORIGIN
,
idx
);
cout
<<
11
<<
endl
;
m_schedule
.
wake_me_on
(
ORIGIN
,
START
(
m_tasks
[
i
]),
idx
);
cout
<<
22
<<
endl
;
m_schedule
.
wake_me_on
(
END
(
m_tasks
[
i
]),
ORIGIN
,
idx
);
m_schedule
.
wake_me_on
(
ORIGIN
,
END
(
m_tasks
[
i
]),
idx
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment