Skip to content
GitLab
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
afa682c1
Commit
afa682c1
authored
Mar 03, 2022
by
ehebrard
Browse files
exampl
parent
ecf4a076
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/src/testsearch.cpp
0 → 100644
View file @
afa682c1
/*************************************************************************
minicsp
Copyright 2010--2011 George Katsirelos
Minicsp is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
Minicsp is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with minicsp. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
#include
<chrono>
#include
<iostream>
#include
<sstream>
#include
<vector>
#include
"TimeTabling.hpp"
#include
"Options.hpp"
#include
"Scheduler.hpp"
#include
"osp.hpp"
using
namespace
std
;
using
namespace
schedcl
;
int
main
(
int
argc
,
char
*
argv
[])
{
Scheduler
<
int
>
S
;
auto
start
=
std
::
chrono
::
system_clock
::
now
();
Options
opt
=
schedcl
::
parse
(
argc
,
argv
);
vector
<
int
>
duration
;
vector
<
vector
<
int
>>
resource
;
osp
::
read_instance
(
opt
.
instance_file
,
duration
,
resource
);
if
(
opt
.
print_ins
)
{
cout
<<
duration
.
size
()
<<
" tasks:"
;
for
(
auto
d
:
duration
)
{
cout
<<
" "
<<
d
;
}
cout
<<
endl
;
cout
<<
resource
.
size
()
<<
" resources:"
;
for
(
auto
R
:
resource
)
{
cout
<<
" ("
;
for
(
auto
x
:
R
)
{
cout
<<
" "
<<
x
;
}
cout
<<
")"
;
}
cout
<<
endl
;
}
for
(
auto
d
:
duration
)
S
.
addTask
(
"t"
+
to_string
(
S
.
numTask
()),
d
,
d
);
auto
ub
{
osp
::
getUb
(
duration
,
resource
)};
S
.
setUpperBound
((
int
)((
double
)
ub
*
.9
));
// cout << S << endl;
vector
<
task
>
scope
;
vector
<
int
>
demand
;
for
(
auto
&
job
:
resource
)
{
demand
.
resize
(
job
.
size
(),
1
);
for
(
auto
j
:
job
)
scope
.
push_back
(
j
);
S
.
post
(
new
CumulativeTimeTabling
<
int
,
int
>
(
S
,
begin
(
scope
),
end
(
scope
),
begin
(
demand
),
end
(
demand
),
1
));
scope
.
clear
();
// cout << S << endl;
}
S
.
initialize
();
S
.
search
();
auto
end
=
std
::
chrono
::
system_clock
::
now
();
auto
elapsed
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
end
-
start
);
cout
<<
"Temps d'execution = "
<<
elapsed
.
count
()
<<
" ms"
<<
endl
;
}
src/cpp/Graph.cpp
View file @
afa682c1
...
...
@@ -485,54 +485,54 @@ void Graph::verify(const char *msg) {
// void EdgeSet::clear(const size_t n) {
// edges.resize(n, 0);
// }
bool
EdgeSet
::
newArc
(
const
int
x
,
const
int
y
)
{
if
(
x
!=
y
)
{
auto
e
{
x
*
size_
+
y
};
assert
(
e
<
edgeset
.
size
());
assert
(
e
>=
0
);
if
(
not
edgeset
[
e
])
{
edgeset
.
set
(
e
);
return
true
;
}
}
return
false
;
}
bool
EdgeSet
::
has
(
const
int
x
,
const
int
y
)
const
{
auto
e
{
x
*
size_
+
y
};
assert
(
e
<
edgeset
.
size
());
assert
(
e
>=
0
);
return
edgeset
[
e
];
}
void
EdgeSet
::
remove
(
const
Arc
a
)
{
auto
e
{
a
[
0
]
*
size_
+
a
[
1
]};
assert
(
e
<
edgeset
.
size
());
assert
(
e
>=
0
);
assert
(
edgeset
[
a
[
0
]
*
size_
+
a
[
1
]]);
edgeset
.
reset
(
e
);
}
ostream
&
EdgeSet
::
display
(
ostream
&
os
)
const
{
for
(
auto
u
{
0
};
u
<
size_
;
++
u
)
{
for
(
auto
v
{
0
};
v
<
size_
;
++
v
)
{
if
(
has
(
u
,
v
))
os
<<
" ("
<<
u
<<
","
<<
v
<<
")"
;
}
}
return
os
;
}
size_t
EdgeSet
::
count
()
const
{
return
edgeset
.
count
();
}
//
//
bool EdgeSet::newArc(const int x, const int y) {
//
if (x != y) {
//
auto e{x * size_ + y};
//
//
assert(e < edgeset.size());
//
assert(e >= 0);
//
//
if (not edgeset[e]) {
//
edgeset.set(e);
//
return true;
//
}
//
}
//
return false;
//
}
//
//
bool EdgeSet::has(const int x, const int y) const {
//
//
auto e{x * size_ + y};
//
//
assert(e < edgeset.size());
//
assert(e >= 0);
//
//
return edgeset[e];
//
}
//
//
void EdgeSet::remove(const Arc a) {
//
//
auto e{a[0] * size_ + a[1]};
//
assert(e < edgeset.size());
//
assert(e >= 0);
//
//
assert(edgeset[a[0] * size_ + a[1]]);
//
//
edgeset.reset(e);
//
}
//
//
ostream& EdgeSet::display(ostream& os) const {
//
for(auto u{0}; u<size_; ++u) {
//
for(auto v{0}; v<size_; ++v) {
//
if(has(u,v))
//
os << " (" << u << "," << v << ")";
//
}
//
}
//
return os;
//
}
//
//
size_t EdgeSet::count() const { return edgeset.count(); }
...
...
@@ -632,9 +632,9 @@ std::ostream &schedcl::operator<<(std::ostream &os, const schedcl::Graph &x) {
}
std
::
ostream
&
schedcl
::
operator
<<
(
std
::
ostream
&
os
,
const
schedcl
::
EdgeSet
&
x
)
{
return
x
.
display
(
os
);
}
//
std::ostream &schedcl::operator<<(std::ostream &os, const schedcl::EdgeSet &x) {
//
return x.display(os);
//
}
...
...
src/header/Graph.hpp
View file @
afa682c1
...
...
@@ -26,23 +26,23 @@ private:
int
elt
[
2
]
=
{
-
1
,
-
1
};
};
class
EdgeSet
{
public:
template
<
typename
vertices
,
typename
edges
>
void
resize
(
const
vertices
&
V
,
const
edges
&
E
);
bool
has
(
const
int
x
,
const
int
y
)
const
;
bool
newArc
(
const
int
x
,
const
int
y
);
void
remove
(
const
Arc
a
);
ostream
&
display
(
ostream
&
os
)
const
;
size_t
count
()
const
;
private:
boost
::
dynamic_bitset
<>
edgeset
;
size_t
size_
{
0
};
};
//
class EdgeSet {
//
//
public:
//
template <typename vertices, typename edges>
//
void resize(const vertices &V, const edges &E);
//
//
bool has(const int x, const int y) const;
//
bool newArc(const int x, const int y);
//
void remove(const Arc a);
//
//
ostream& display(ostream& os) const;
//
size_t count() const;
//
//
private:
//
boost::dynamic_bitset<> edgeset;
//
size_t size_{0};
//
};
class
ReversibleEdgeSet
:
public
ReversibleObject
{
...
...
@@ -163,28 +163,28 @@ private:
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Graph
&
x
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
EdgeSet
&
x
);
template
<
typename
vertices
,
typename
edges
>
void
EdgeSet
::
resize
(
const
vertices
&
V
,
const
edges
&
E
)
{
auto
nsize
{
V
.
capacity
()};
edgeset
.
resize
(
nsize
*
nsize
,
0
);
for
(
auto
u
{
size_
};
u
-->
0
;)
{
for
(
auto
v
{
size_
};
v
-->
0
;)
{
if
(
has
(
u
,
v
))
{
edgeset
.
set
(
u
*
nsize
+
v
);
edgeset
.
reset
(
u
*
size_
+
v
);
}
}
}
size_
=
nsize
;
// edgeset.reset();
// for (auto u : V) {
// for (auto v : E[u]) {
// edgeset.set(u * size_ + v);
// }
// }
}
//
std::ostream &operator<<(std::ostream &os, const EdgeSet &x);
//
template <typename vertices, typename edges>
//
void EdgeSet::resize(const vertices &V, const edges &E) {
//
auto nsize{V.capacity()};
//
edgeset.resize(nsize * nsize, 0);
//
for(auto u{size_}; u-->0;) {
//
for(auto v{size_}; v-->0;) {
//
if(has(u,v)) {
//
edgeset.set(u * nsize + v);
//
edgeset.reset(u * size_ + v);
//
}
//
}
//
}
//
size_ = nsize;
//
// edgeset.reset();
//
// for (auto u : V) {
//
// for (auto v : E[u]) {
//
// edgeset.set(u * size_ + v);
//
// }
//
// }
//
}
...
...
src/header/Scheduler.hpp
View file @
afa682c1
...
...
@@ -762,8 +762,8 @@ void Scheduler<T>::updateNetwork(vector<event>::const_iterator first) {
}
}
#endif
network
.
merge
(
the_rep
,
to_merge
);
if
(
rep_event
!=
rep_other
)
network
.
merge
(
the_rep
,
to_merge
);
}
to_merge
=
getVariable
(
other_event
,
merged_event
);
...
...
@@ -785,7 +785,8 @@ void Scheduler<T>::updateNetwork(vector<event>::const_iterator first) {
}
#endif
network
.
merge
(
the_rep
,
to_merge
);
if
(
rep_event
!=
rep_other
)
network
.
merge
(
the_rep
,
to_merge
);
}
}
#ifdef DEBUG_MERGE
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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