Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
CoMISo
Commits
a0e47ef4
Commit
a0e47ef4
authored
Sep 28, 2017
by
Martin Marinov
Browse files
Minor improvements to code whitespace style and clarity. Add some progress ticks.
parent
dcc31ac2
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Solver/ConstrainedSolverT.cc
View file @
a0e47ef4
This diff is collapsed.
Click to expand it.
Solver/GMM_ToolsT.cc
View file @
a0e47ef4
...
...
@@ -35,11 +35,13 @@
//== INCLUDES =================================================================
#include
"GMM_Tools.hh"
#define GMM_USES_LAPACK
#include
<gmm/gmm_lapack_interface.h>
#include
<queue>
#include
<CoMISo/Utils/VSToolsT.hh>
#include
<CoMISo/Utils/VSToolsT.hh>
#include
<Base/Debug/DebOut.hh>
#include
<queue>
//== NAMESPACES ===============================================================
...
...
@@ -961,19 +963,19 @@ int gauss_seidel_local( MatrixT& _A, VectorT& _x, VectorT& _rhs, std::vector<uns
template
<
class
MatrixT
,
class
VectorT
>
double
residuum_norm
(
MatrixT
&
_A
,
VectorT
&
_x
,
VectorT
&
_rhs
)
{
if
(
gmm
::
mat_ncols
(
_A
)
!=
_x
.
size
()
)
std
::
cerr
<<
"DIM ERROR (residuum_norm): "
<<
gmm
::
mat_ncols
(
_A
)
<<
" vs "
<<
_x
.
size
()
<<
std
::
endl
;
if
(
gmm
::
mat_nrows
(
_A
)
!=
_rhs
.
size
()
)
std
::
cerr
<<
"DIM ERROR 2 (residuum_norm): "
<<
gmm
::
mat_nrows
(
_A
)
<<
" vs "
<<
_rhs
.
size
()
<<
std
::
endl
;
if
(
gmm
::
mat_ncols
(
_A
)
!=
_x
.
size
())
std
::
cerr
<<
"DIM ERROR (residuum_norm): "
<<
gmm
::
mat_ncols
(
_A
)
<<
" vs "
<<
_x
.
size
()
<<
std
::
endl
;
if
(
gmm
::
mat_nrows
(
_A
)
!=
_rhs
.
size
())
std
::
cerr
<<
"DIM ERROR 2 (residuum_norm): "
<<
gmm
::
mat_nrows
(
_A
)
<<
" vs "
<<
_rhs
.
size
()
<<
std
::
endl
;
// temp vectors
VectorT
Ax
(
_rhs
.
size
());
VectorT
res
(
_rhs
.
size
()
);
// temp vectors
VectorT
Ax
(
_rhs
.
size
());
VectorT
res
(
_rhs
.
size
());
gmm
::
mult
(
_A
,
_x
,
Ax
);
gmm
::
add
(
Ax
,
gmm
::
scaled
(
_rhs
,
-
1.0
),
res
);
gmm
::
mult
(
_A
,
_x
,
Ax
);
gmm
::
add
(
Ax
,
gmm
::
scaled
(
_rhs
,
-
1.0
),
res
);
return
gmm
::
vect_norm2
(
res
);
return
gmm
::
vect_norm2
(
res
);
}
...
...
@@ -983,29 +985,31 @@ double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs )
template
<
class
MatrixT
,
class
MatrixT2
,
class
VectorT
>
void
factored_to_quadratic
(
MatrixT
&
_F
,
MatrixT2
&
_Q
,
VectorT
&
_rhs
)
{
DEB_enter_func
;
gmm
::
size_type
m
=
gmm
::
mat_nrows
(
_F
);
gmm
::
size_type
n
=
gmm
::
mat_ncols
(
_F
);
// resize result matrix and vector
gmm
::
resize
(
_Q
,
n
-
1
,
n
-
1
);
gmm
::
resize
(
_Q
,
n
-
1
,
n
-
1
);
gmm
::
resize
(
_rhs
,
n
);
// // set up transposed
// MatrixT Ft(n,m);
// gmm::copy(gmm::transposed(_F), Ft);
// // set up transposed
// MatrixT Ft(n,m);
// gmm::copy(gmm::transposed(_F), Ft);
// compute quadratic matrix
MatrixT
Q
(
n
,
n
);
// gmm::mult(Ft,_F,Q);
gmm
::
mult
(
gmm
::
transposed
(
_F
),
_F
,
Q
);
MatrixT
Q
(
n
,
n
);
// gmm::mult(Ft,_F,Q);
gmm
::
mult
(
gmm
::
transposed
(
_F
),
_F
,
Q
);
PROGRESS_TICK
;
// extract rhs
gmm
::
copy
(
gmm
::
scaled
(
gmm
::
mat_const_row
(
Q
,
n
-
1
),
-
1.0
),
_rhs
);
gmm
::
copy
(
gmm
::
scaled
(
gmm
::
mat_const_row
(
Q
,
n
-
1
),
-
1.0
),
_rhs
);
// resize and copy output
gmm
::
resize
(
Q
,
n
-
1
,
n
-
1
);
_rhs
.
resize
(
n
-
1
);
gmm
::
copy
(
Q
,
_Q
);
gmm
::
resize
(
Q
,
n
-
1
,
n
-
1
);
_rhs
.
resize
(
n
-
1
);
PROGRESS_TICK
;
gmm
::
copy
(
Q
,
_Q
);
}
...
...
Solver/MISolver.cc
View file @
a0e47ef4
...
...
@@ -97,22 +97,22 @@ MISolver::solve(
DEB_out
(
2
,
"# integer variables: "
<<
_to_round
.
size
()
<<
"
\n
# continuous variables: "
<<
_x
.
size
()
-
_to_round
.
size
()
<<
"
\n
"
)
// nothing to solve?
if
(
gmm
::
mat_ncols
(
_A
)
==
0
||
gmm
::
mat_nrows
(
_A
)
==
0
)
return
;
if
(
gurobi_rounding_
)
solve_gurobi
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
cplex_rounding_
)
solve_cplex
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
no_rounding_
||
_to_round
.
size
()
==
0
)
solve_no_rounding
(
_A
,
_x
,
_rhs
);
else
if
(
direct_rounding_
)
solve_direct_rounding
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
multiple_rounding_
)
solve_multiple_rounding
(
_A
,
_x
,
_rhs
,
_to_round
);
else
solve_iterative
(
_A
,
_x
,
_rhs
,
_to_round
,
_fixed_order
);
// nothing to solve?
if
(
gmm
::
mat_ncols
(
_A
)
==
0
||
gmm
::
mat_nrows
(
_A
)
==
0
)
return
;
if
(
gurobi_rounding_
)
solve_gurobi
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
cplex_rounding_
)
solve_cplex
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
no_rounding_
||
_to_round
.
size
()
==
0
)
solve_no_rounding
(
_A
,
_x
,
_rhs
);
else
if
(
direct_rounding_
)
solve_direct_rounding
(
_A
,
_x
,
_rhs
,
_to_round
);
else
if
(
multiple_rounding_
)
solve_multiple_rounding
(
_A
,
_x
,
_rhs
,
_to_round
);
else
solve_iterative
(
_A
,
_x
,
_rhs
,
_to_round
,
_fixed_order
);
}
...
...
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