Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Discrete Optimization Library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bachelorarbeit
Discrete Optimization Library
Commits
28185801
Commit
28185801
authored
Sep 07, 2020
by
Jonas Seidel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Special members and operators (assortment)
parent
c8feba89
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
7 deletions
+101
-7
Graphtheory/Basic_Graph.h
Graphtheory/Basic_Graph.h
+6
-0
Graphtheory/Basic_Graph.ipp
Graphtheory/Basic_Graph.ipp
+2
-2
Graphtheory/Basic_Graph_special_members_and_operators.ipp
Graphtheory/Basic_Graph_special_members_and_operators.ipp
+41
-0
Linear_Programming/Linear_Program.cpp
Linear_Programming/Linear_Program.cpp
+26
-2
Linear_Programming/Linear_Program.h
Linear_Programming/Linear_Program.h
+6
-1
Linear_Programming/Polyeder.cpp
Linear_Programming/Polyeder.cpp
+16
-2
Linear_Programming/Polyeder.h
Linear_Programming/Polyeder.h
+4
-0
No files found.
Graphtheory/Basic_Graph.h
View file @
28185801
...
...
@@ -23,6 +23,8 @@ public:
// TODO: use references to speed up constructors
Graph
(){};
Graph
(
std
::
map
<
E
,
Attribute
>
default_values_edge_attributes
,
std
::
map
<
N
,
Attribute
>
default_values_node_attributes
=
{});
Graph
(
Graph
<
N
,
E
>&
graph
);
Graph
(
Graph
<
N
,
E
>&&
graph
);
Edge
<
N
,
E
>*
add_edge
(
Node
<
N
,
E
>*
from
,
Node
<
N
,
E
>*
to
,
std
::
map
<
E
,
Attribute
>
edge_attributes
=
{});
Edge
<
N
,
E
>*
add_edge
(
Node
<
N
,
E
>*
from
,
Node
<
N
,
E
>*
to
,
std
::
map
<
E
,
double
>
edge_attributes
);
...
...
@@ -60,6 +62,9 @@ public:
// _advanced.cpp:
void
conditional_bfs_all_components
(
std
::
function
<
void
(
Node
<
N
,
E
>*
from
,
Edge
<
N
,
E
>*
via
,
bool
used_in_traversal
)
>
edge_exec
,
std
::
function
<
void
(
Node
<
N
,
E
>*
)
>
node_exec
,
std
::
function
<
bool
(
Node
<
N
,
E
>*
from
,
Edge
<
N
,
E
>*
via
)
>
guide
=
[](
Node
<
N
,
E
>*
n
,
Edge
<
N
,
E
>*
e
)
->
bool
{
return
e
->
from
()
==
n
;});
// _special_members_and_operators:
void
operator
=
(
Graph
<
N
,
E
>&
graph
);
void
operator
=
(
Graph
<
N
,
E
>&&
graph
);
};
template
<
typename
N
,
typename
E
>
...
...
@@ -67,5 +72,6 @@ std::ostream& operator<<(std::ostream& os, Graph<N,E>& g);
#include "Basic_Graph.ipp"
#include "Basic_Graph_advanced.ipp"
#include "Basic_Graph_special_members_and_operators.ipp"
#endif
Graphtheory/Basic_Graph.ipp
View file @
28185801
template <typename
E_N, typename E_
E>
Graph<
E_N,E_E>::Graph(std::map<E_E,Attribute> default_values_edge_attributes, std::map<E_
N,Attribute> default_values_node_attributes) : _template_node_attributes(default_values_node_attributes), _template_edge_attributes(default_values_edge_attributes){}
template <typename
N, typename
E>
Graph<
N,E>::Graph(std::map<E,Attribute> default_values_edge_attributes, std::map<
N,Attribute> default_values_node_attributes) : _template_node_attributes(default_values_node_attributes), _template_edge_attributes(default_values_edge_attributes){}
template <typename N, typename E>
Edge<N,E>* Graph<N,E>::add_edge(Node<N, E>* from, Node<N, E>* to, std::map<E,Attribute> edge_attributes){
...
...
Graphtheory/Basic_Graph_special_members_and_operators.ipp
0 → 100644
View file @
28185801
template <typename N, typename E>
Graph<N,E>::Graph(Graph<N,E>& graph){
*this = graph;
}
template <typename N, typename E>
Graph<N,E>::Graph(Graph<N,E>&& graph)
: _edges(std::move(graph._edges)), _nodes(std::move(graph._nodes)),
_template_node_attributes(std::move(graph._template_node_attributes)), _template_edge_attributes(std::move(graph._template_edge_attributes)) {
graph._nodes = {};
graph._edges = {};
graph._template_node_attributes = {};
graph._template_edge_attributes = {};
}
template <typename N, typename E>
void Graph<N,E>::operator=(Graph<N,E>& graph){
std::map<Node<N,E>*, Node<N,E>*> node_lookup;
graph.conditional_bfs_all_components(
[&node_lookup, this](Node<N,E>* node, Edge<N,E>* edge, bool used_in_traversal){
this->add_edge(edge, node_lookup);
},
[&node_lookup, this](Node<N,E>* node){
Node<N,E>* new_node = this->add_node(node);
node_lookup.insert({node, new_node});
}
);
}
template <typename N, typename E>
void Graph<N,E>::operator=(Graph<N,E>&& graph){
this->_edges = std::move(graph._edges);
this->_nodes = std::move(graph._nodes);
this->_template_node_attributes = std::move(graph._template_node_attributes);
this->_template_edge_attributes = std::move(graph._template_edge_attributes);
graph._nodes = {};
graph._edges = {};
graph._template_node_attributes = {};
graph._template_edge_attributes = {};
}
Linear_Programming/Linear_Program.cpp
View file @
28185801
#include "Linear_Program.h"
Linear_Program
::
Linear_Program
(
std
::
vector
<
double
>
direction
,
Polyeder
&
polyeder
)
:
_direction
(
direction
),
_polyeder
(
polyeder
){}
Linear_Program
::
Linear_Program
(
Linear_Program
&
lp
){
*
this
=
lp
;
}
Linear_Program
::
Linear_Program
(
Linear_Program
&&
lp
){
*
this
=
std
::
move
(
lp
);
}
Linear_Program
::
Linear_Program
(
bool
maximum
)
:
_maximum
(
maximum
)
{}
Linear_Program
::
Linear_Program
(
bool
maximum
,
size_t
direction_start
,
std
::
vector
<
double
>
direction
,
Polyeder
&
polyeder
)
:
_maximum
(
maximum
),
_direction_start
(
direction_start
),
_direction
(
direction
),
_polyeder
(
polyeder
)
{}
bool
Linear_Program
::
is_maximum
(){
return
this
->
_maximum
;
...
...
@@ -19,6 +29,20 @@ std::vector<double> Linear_Program::direction(){
return
this
->
_direction
;
}
void
Linear_Program
::
operator
=
(
Linear_Program
&
lp
){
this
->
_maximum
=
lp
.
_maximum
;
this
->
_direction_start
=
lp
.
_direction_start
;
this
->
_direction
=
lp
.
_direction
;
this
->
_polyeder
=
lp
.
_polyeder
;
}
void
Linear_Program
::
operator
=
(
Linear_Program
&&
lp
){
this
->
_maximum
=
lp
.
_maximum
;
this
->
_direction_start
=
lp
.
_direction_start
;
this
->
_direction
=
std
::
move
(
lp
.
_direction
);
this
->
_polyeder
=
std
::
move
(
lp
.
_polyeder
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Linear_Program
&
linear_program
){
if
(
linear_program
.
is_maximum
()){
os
<<
"Maximize
\n
"
;
...
...
Linear_Programming/Linear_Program.h
View file @
28185801
...
...
@@ -11,12 +11,17 @@ class Linear_Program{
std
::
vector
<
double
>
_direction
;
Polyeder
_polyeder
;
public:
Linear_Program
(
std
::
vector
<
double
>
direction
,
Polyeder
&
polyeder
);
Linear_Program
(
Linear_Program
&
lp
);
Linear_Program
(
Linear_Program
&&
lp
);
Linear_Program
(
bool
maximum
);
Linear_Program
(
bool
maximum
,
size_t
direction_start
,
std
::
vector
<
double
>
direction
,
Polyeder
&
polyeder
);
bool
is_maximum
();
double
direction_coefficient
(
size_t
index
);
Polyeder
&
polyeder
();
std
::
vector
<
double
>
direction
();
void
operator
=
(
Linear_Program
&
lp
);
void
operator
=
(
Linear_Program
&&
lp
);
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Linear_Program
&
linear_program
);
...
...
Linear_Programming/Polyeder.cpp
View file @
28185801
...
...
@@ -2,9 +2,13 @@
Polyeder
::
Polyeder
(){}
Polyeder
::
Polyeder
(
const
Polyeder
&
p
){
*
this
=
p
;
}
Polyeder
::
Polyeder
(
std
::
vector
<
Constraint
>
constraints
,
std
::
vector
<
Variable
>
variables
)
:
_constraints
(
constraints
),
_variables
(
variables
)
{
for
(
Constraint
i
:
this
->
_constraints
){
assert
(
i
.
lhs_last_variable
()
==
variables
.
size
());
for
(
Constraint
c
:
this
->
_constraints
){
assert
(
c
.
lhs_end
()
==
variables
.
size
());
}
}
...
...
@@ -43,6 +47,16 @@ void Polyeder::add_constraint(Constraint constraint){
this
->
_constraints
.
push_back
(
constraint
);
}
void
Polyeder
::
operator
=
(
const
Polyeder
&
p
){
this
->
_constraints
=
p
.
_constraints
;
this
->
_variables
=
p
.
_variables
;
}
void
Polyeder
::
operator
=
(
Polyeder
&&
p
){
this
->
_constraints
=
std
::
move
(
p
.
_constraints
);
this
->
_variables
=
std
::
move
(
p
.
_variables
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Polyeder
&
polyeder
){
os
<<
"Subject to
\n
"
;
for
(
size_t
index
=
0
;
index
<
polyeder
.
number_of_constraints
();
index
++
)
{
...
...
Linear_Programming/Polyeder.h
View file @
28185801
...
...
@@ -13,6 +13,7 @@ class Polyeder{
std
::
vector
<
Variable
>
_variables
;
public:
Polyeder
();
Polyeder
(
const
Polyeder
&
p
);
Polyeder
(
std
::
vector
<
Constraint
>
constraints
,
std
::
vector
<
Variable
>
variables
);
...
...
@@ -25,6 +26,9 @@ public:
size_t
number_of_constraints
();
Constraint
&
constraint
(
size_t
index
);
void
add_constraint
(
Constraint
inequality
);
void
operator
=
(
const
Polyeder
&
p
);
void
operator
=
(
Polyeder
&&
p
);
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Polyeder
&
polyeder
);
...
...
Write
Preview
Markdown
is supported
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