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
15b5154a
Commit
15b5154a
authored
Jan 29, 2018
by
Max Lyon
Browse files
Merge branch 'master' into gurobi_const
parents
a925455a
45d01e0f
Pipeline
#6103
passed with stages
in 7 minutes and 9 seconds
Changes
16
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
15b5154a
...
...
@@ -18,6 +18,9 @@ CoMISo-VS2013-Qt-5.5.1-x64:
BUILD_PLATFORM
:
"
VS2013"
ARCHITECTURE
:
"
x64"
QT_VERSION
:
"
Qt5.5.1"
GIT_SUBMODULE_STRATEGY
:
recursive
COMPILER
:
"
VS2013"
script
:
"
CI
\\
Windows.bat"
tags
:
-
VS2013
...
...
Base
@
d8f56549
Subproject commit
86ada33be371319082946389b144b7b6acf9c9d3
Subproject commit
d8f56549c8f6c55ae76aaed6f2ff8159d93c0d5f
CI/Windows.bat
View file @
15b5154a
git
submodule
init
git
submodule
update
--remote
:: set up Libraty Paths
set
LIBPATH_BASE
=
E
:/libs/
%COMPILER%
set
CMAKE_WINDOWS_LIBS_DIR
=
E
:/libs
mkdir
rel
cd
rel
...
...
@@ -25,7 +31,7 @@ IF "%QT_VERSION%" == "Qt5.5.1" (
IF
"
%BUILD_PLATFORM%
"
==
"VS2013"
(
set
LIBPATH
=
C
:/libs/VS2013
set
LIBPATH
=
E
:/libs/VS2013
set
GTESTVERSION
=
gtest
-
1
.6.0
set
GENERATOR
=
Visual
Studio
12
%ARCH_VS%
set
VS_PATH
=
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com"
...
...
@@ -41,7 +47,7 @@ IF "%BUILD_PLATFORM%" == "VS2013" (
)
IF
"
%BUILD_PLATFORM%
"
==
"VS2015"
(
set
LIBPATH
=
C
:/libs/VS2015
set
LIBPATH
=
E
:/libs/VS2015
set
GTESTVERSION
=
gtest
-
1
.7.0
set
GENERATOR
=
Visual
Studio
14
%ARCH_VS%
set
VS_PATH
=
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com"
...
...
@@ -50,7 +56,7 @@ IF "%BUILD_PLATFORM%" == "VS2015" (
set
CMAKE_CONFIGURATION
=
%QT_BASE_CONFIG%
-DGLUT
_INCLUDE_DIR
=
"
%LIBPATH%
\
%ARCHITECTURE%
\freeglut-2.8.1\include"
-DGLUT
_glut_LIBRARY
=
"
%LIBPATH%
\
%ARCHITECTURE%
\freeglut-2.8.1\lib\freeglut.lib"
-DGLEW
_INCLUDE_DIR
=
"
%LIBPATH%
\
%ARCHITECTURE%
\glew-1.10.0\include"
-DGLEW
_LIBRARY
=
"
%LIBPATH%
\
%ARCHITECTURE%
\glew-1.10.0\lib\glew32.lib"
-DBOOST
_ROOT
=
"
%LIBPATH%
/
%ARCHITECTURE%
/boost_1_59_0"
-DBOOST
_LIBRARYDIR
=
"
%LIBPATH%
/
%ARCHITECTURE%
/boost_1_59_0/lib64-msvc-12.0"
-DCGAL
_INCLUDE_DIR
=
"
%LIBPATH%
/
%ARCHITECTURE%
/CGAL-4.7/include"
-DCGAL
_LIBRARY_DIR
=
"
%LIBPATH%
/
%ARCHITECTURE%
/CGAL-4.7/lib"
-DCGAL
_BIN_DIR
=
"
%LIBPATH%
/
%ARCHITECTURE%
/CGAL-4.7/bin"
-DMUMPS
_INCLUDE_DIR
=
"
%LIBPATH%
/
%ARCHITECTURE%
/Ipopt-3.11.9/Ipopt/MSVisualStudio/v8-ifort/installed/include"
-DMUMPS
_LIBRARY
=
"
%LIBPATH%
/
%ARCHITECTURE%
/Ipopt-3.11.9/Ipopt/MSVisualStudio/v8-ifort/installed/lib/CoinMumpsC.lib"
"C:\Program Files (x86)\CMake\bin\cmake.exe"
-DGTEST
_PREFIX
=
"
%LIBPATH%
\
%ARCHITECTURE%
\
%GTESTVERSION%
"
-G
"
%GENERATOR%
"
-DCMAKE
_BUILD_TYPE
=
Release
-DOPENFLIPPER
_BUILD_UNIT_TESTS
=
TRUE
%CMAKE_CONFIGURATION%
..
"C:\Program Files (x86)\CMake\bin\cmake.exe"
-DGTEST
_PREFIX
=
"
%LIBPATH%
\
%ARCHITECTURE%
\
%GTESTVERSION%
"
-G
"
%GENERATOR%
"
-DCMAKE
_BUILD_TYPE
=
Release
-DOPENFLIPPER
_BUILD_UNIT_TESTS
=
TRUE
-DCMAKE
_WINDOWS_LIBS_DIR
=
%CMAKE_WINDOWS_LIBS_DIR%
%CMAKE_CONFIGURATION%
..
IF
%errorlevel%
NEQ
0
exit
/b
%errorlevel%
...
...
CMakeLists.txt
View file @
15b5154a
...
...
@@ -293,6 +293,18 @@ else ()
set
(
COMISO_GUROBI_CONFIG_FILE_SETTINGS
"#define COMISO_GUROBI_AVAILABLE 0"
)
endif
()
find_package
(
MOSEK
)
if
(
MOSEK_FOUND
)
set
(
COMISO_MOSEK_CONFIG_FILE_SETTINGS
"#define COMISO_MOSEK_AVAILABLE 1"
)
list
(
APPEND COMISO_INCLUDE_DIRECTORIES
${
MOSEK_INCLUDE_DIRS
}
)
list
(
APPEND COMISO_LINK_DIRECTORIES
${
MOSEK_LIBRARY_DIR
}
)
list
(
APPEND COMISO_LINK_LIBRARIES
${
MOSEK_LIBRARIES
}
)
else
()
message
(
STATUS
"MOSEK not found!"
)
set
(
COMISO_MOSEK_CONFIG_FILE_SETTINGS
"#define COMISO_MOSEK_AVAILABLE 0"
)
endif
()
find_package
(
ARPACK
)
if
(
ARPACK_FOUND
)
set
(
COMISO_ARPACK_CONFIG_FILE_SETTINGS
"#define COMISO_ARPACK_AVAILABLE 1"
)
...
...
@@ -352,7 +364,10 @@ link_directories (
)
# enable debug stuff
add_definitions
(
-DDEB_ON
)
set
(
COMISO_ENABLE_DEBUG_OUTPUT TRUE CACHE BOOL
"Enable CoMISo Debug Output"
)
if
(
COMISO_ENABLE_DEBUG_OUTPUT
)
add_definitions
(
-DDEB_ON
)
endif
()
# source code directories
set
(
directories
...
...
@@ -508,6 +523,15 @@ if (COMISO_BUILD_EXAMPLES )
if
(
EXISTS
"
${
CMAKE_SOURCE_DIR
}
/Examples/small_AQP/CMakeLists.txt"
)
add_subdirectory
(
Examples/small_AQP
)
endif
()
if
(
EXISTS
"
${
CMAKE_SOURCE_DIR
}
/Examples/finite_element_integrability_problem/CMakeLists.txt"
)
add_subdirectory
(
Examples/finite_element_integrability_problem
)
endif
()
if
(
EXISTS
"
${
CMAKE_SOURCE_DIR
}
/Examples/small_mosek_native/CMakeLists.txt"
)
add_subdirectory
(
Examples/small_mosek_native
)
endif
()
if
(
EXISTS
"
${
CMAKE_SOURCE_DIR
}
/Examples/small_mosek_fusion_sdp/CMakeLists.txt"
)
add_subdirectory
(
Examples/small_mosek_fusion_sdp
)
endif
()
endif
(
COMISO_BUILD_EXAMPLES
)
...
...
Config/CoMISoDefines.hh
View file @
15b5154a
...
...
@@ -33,12 +33,19 @@
#define COMISODLLEXPORTONLY __declspec(dllexport)
#endif
#else
#define COMISODLLEXPORT
#define COMISODLLEXPORTONLY
#define COMISODLLEXPORT
#define COMISODLLEXPORTONLY
#endif
#else
#define COMISODLLEXPORT
#define COMISODLLEXPORTONLY
#else // non-Windows symbols export:
#ifdef COMISODLL
// only export symbols if COMISODLL is defined (same behavior as Windows)
#define COMISODLLEXPORT __attribute__((visibility("default")))
#define COMISODLLEXPORTONLY COMISODLLEXPORT
#else // COMISODLL not defined
// this allows building CoMISo as static library without exposing its symbols
#define COMISODLLEXPORT
#define COMISODLLEXPORTONLY
#endif // COMISODLL
#endif
#endif
...
...
Config/config.hh.in
View file @
15b5154a
...
...
@@ -25,3 +25,4 @@
@COMISO_CLP_CONFIG_FILE_SETTINGS@
@COMISO_CGL_CONFIG_FILE_SETTINGS@
@COMISO_COINUTILS_CONFIG_FILE_SETTINGS@
@COMISO_MOSEK_CONFIG_FILE_SETTINGS@
NSolver/FiniteElementLogBarrier.hh
0 → 100644
View file @
15b5154a
//=============================================================================
//
// CLASS FiniteElementLogBarrier
//
//=============================================================================
#ifndef COMISO_FINITEELEMENTLOGBARRIER_HH
#define COMISO_FINITEELEMENTLOGBARRIER_HH
//== INCLUDES =================================================================
#include
<CoMISo/Config/CoMISoDefines.hh>
#include
"NProblemInterface.hh"
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace
COMISO
{
//== CLASS DEFINITION =========================================================
/** \class FiniteElementLogBarrierLowerBound
Implements function of the type f(x) = -c1*log(x-c0) with constants (c0,c1)
A more elaborate description follows.
*/
class
FiniteElementLogBarrierLowerBound
{
public:
// define dimensions
const
static
int
NV
=
1
;
const
static
int
NC
=
2
;
typedef
Eigen
::
Matrix
<
size_t
,
NV
,
1
>
VecI
;
typedef
Eigen
::
Matrix
<
double
,
NV
,
1
>
VecV
;
typedef
Eigen
::
Matrix
<
double
,
NC
,
1
>
VecC
;
typedef
Eigen
::
Triplet
<
double
>
Triplet
;
inline
double
eval_f
(
const
VecV
&
_x
,
const
VecC
&
_c
)
const
{
return
-
_c
[
1
]
*
std
::
log
(
_x
[
0
]
-
_c
[
0
]);
}
inline
void
eval_gradient
(
const
VecV
&
_x
,
const
VecC
&
_c
,
VecV
&
_g
)
const
{
_g
[
0
]
=
-
_c
[
1
]
/
(
_x
[
0
]
-
_c
[
0
]);
}
inline
void
eval_hessian
(
const
VecV
&
_x
,
const
VecC
&
_c
,
std
::
vector
<
Triplet
>&
_triplets
)
const
{
_triplets
.
clear
();
_triplets
.
push_back
(
Triplet
(
0
,
0
,
_c
[
1
]
/
std
::
pow
(
_x
[
0
]
-
_c
[
0
],
2
)));
}
inline
double
max_feasible_step
(
const
VecV
&
_x
,
const
VecV
&
_v
,
const
VecC
&
_c
)
{
if
(
_v
[
0
]
>=
0.0
)
return
DBL_MAX
;
else
return
0.999
*
(
_c
[
0
]
-
_x
[
0
])
/
_v
[
0
];
}
};
/** \class FiniteElementLogBarrierUpperBound
Implements function of the type f(x) = -c1*log(c0-x) with constants (c0,c1)
A more elaborate description follows.
*/
class
FiniteElementLogBarrierUpperBound
{
public:
// define dimensions
const
static
int
NV
=
1
;
const
static
int
NC
=
2
;
typedef
Eigen
::
Matrix
<
size_t
,
NV
,
1
>
VecI
;
typedef
Eigen
::
Matrix
<
double
,
NV
,
1
>
VecV
;
typedef
Eigen
::
Matrix
<
double
,
NC
,
1
>
VecC
;
typedef
Eigen
::
Triplet
<
double
>
Triplet
;
inline
double
eval_f
(
const
VecV
&
_x
,
const
VecC
&
_c
)
const
{
return
-
_c
[
1
]
*
std
::
log
(
_c
[
0
]
-
_x
[
0
]);
}
inline
void
eval_gradient
(
const
VecV
&
_x
,
const
VecC
&
_c
,
VecV
&
_g
)
const
{
_g
[
0
]
=
_c
[
1
]
/
(
_c
[
0
]
-
_x
[
0
]);
}
inline
void
eval_hessian
(
const
VecV
&
_x
,
const
VecC
&
_c
,
std
::
vector
<
Triplet
>&
_triplets
)
const
{
_triplets
.
clear
();
_triplets
.
push_back
(
Triplet
(
0
,
0
,
_c
[
1
]
/
std
::
pow
(
_c
[
0
]
-
_x
[
0
],
2
)));
}
inline
double
max_feasible_step
(
const
VecV
&
_x
,
const
VecV
&
_v
,
const
VecC
&
_c
)
{
if
(
_v
[
0
]
<=
0.0
)
return
DBL_MAX
;
else
return
0.999
*
(
_c
[
0
]
-
_x
[
0
])
/
_v
[
0
];
}
};
//=============================================================================
}
// namespace COMISO
//=============================================================================
#endif // COMISO_FINITEELEMENTLOGBARRIER_HH defined
//=============================================================================
NSolver/IPOPTSolver.hh
View file @
15b5154a
...
...
@@ -101,6 +101,8 @@ public:
// access the ipopt-application (for setting parameters etc.)
// examples: app().Options()->SetIntegerValue("max_iter", 100);
// app().Options()->SetStringValue("derivative_test", "second-order");
// app().Options()->SetStringValue("hessian_approximation", "limited-memory");
Ipopt
::
IpoptApplication
&
app
()
{
return
(
*
app_
);
}
...
...
NSolver/IPOPTSolverLean.cc
View file @
15b5154a
...
...
@@ -323,7 +323,10 @@ void IPOPTSolverLean::solve(
//----------------------------------------------------------------------------
// 3. solve problem
//----------------------------------------------------------------------------
status
=
impl_
->
app_
->
OptimizeTNLP
(
np
);
{
DEB_time_session_def
(
"IPOPT App OptimizeTNLP(np)"
);
status
=
impl_
->
app_
->
OptimizeTNLP
(
np
);
}
check_ipopt_status
(
status
);
...
...
NSolver/NProblemIPOPT.hh
View file @
15b5154a
...
...
@@ -127,6 +127,21 @@ public:
IpoptCalculatedQuantities
*
ip_cq
);
//@}
/** Intermediate Callback method for the user. Providing dummy
* default implementation. For details see IntermediateCallBack
* in IpNLP.hpp. */
virtual
bool
intermediate_callback
(
Ipopt
::
AlgorithmMode
mode
,
Index
iter
,
Number
obj_value
,
Number
inf_pr
,
Number
inf_du
,
Number
mu
,
Number
d_norm
,
Number
regularization_size
,
Number
alpha_du
,
Number
alpha_pr
,
Index
ls_trials
,
const
IpoptData
*
ip_data
,
IpoptCalculatedQuantities
*
ip_cq
)
override
;
// special properties of problem
bool
hessian_constant
()
const
;
bool
jac_c_constant
()
const
;
...
...
@@ -270,6 +285,22 @@ public:
IpoptCalculatedQuantities
*
ip_cq
);
//@}
/** Intermediate Callback method for the user. Providing dummy
* default implementation. For details see IntermediateCallBack
* in IpNLP.hpp. */
virtual
bool
intermediate_callback
(
Ipopt
::
AlgorithmMode
mode
,
Index
iter
,
Number
obj_value
,
Number
inf_pr
,
Number
inf_du
,
Number
mu
,
Number
d_norm
,
Number
regularization_size
,
Number
alpha_du
,
Number
alpha_pr
,
Index
ls_trials
,
const
IpoptData
*
ip_data
,
IpoptCalculatedQuantities
*
ip_cq
)
override
;
private:
/**@name Methods to block default compiler methods.
* The compiler automatically generates the following three methods.
...
...
NSolver/NProblemIPOPTc.cc
View file @
15b5154a
...
...
@@ -40,6 +40,7 @@ void
NProblemIPOPT
::
split_constraints
(
const
std
::
vector
<
NConstraintInterface
*>&
_constraints
)
{
DEB_enter_func
;
// split user-provided constraints into general-constraints and bound-constraints
constraints_
.
clear
();
constraints_
.
reserve
(
_constraints
.
size
());
bound_constraints_
.
clear
();
bound_constraints_
.
reserve
(
_constraints
.
size
());
...
...
@@ -100,6 +101,7 @@ analyze_special_properties(const NProblemInterface* _problem, const std::vector<
bool
NProblemIPOPT
::
get_nlp_info
(
Index
&
n
,
Index
&
m
,
Index
&
nnz_jac_g
,
Index
&
nnz_h_lag
,
IndexStyleEnum
&
index_style
)
{
DEB_enter_func
;
// number of variables
n
=
static_cast
<
Index
>
(
problem_
->
n_unknowns
());
...
...
@@ -233,6 +235,7 @@ bool NProblemIPOPT::get_starting_point(Index n, bool init_x, Number* x,
Index
m
,
bool
init_lambda
,
Number
*
lambda
)
{
DEB_enter_func
;
// get initial value of problem instance
problem_
->
initial_x
(
x
);
...
...
@@ -245,6 +248,7 @@ bool NProblemIPOPT::get_starting_point(Index n, bool init_x, Number* x,
bool
NProblemIPOPT
::
eval_f
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Number
&
obj_value
)
{
DEB_enter_func
;
// return the value of the objective function
obj_value
=
problem_
->
eval_f
(
x
);
return
true
;
...
...
@@ -256,6 +260,7 @@ bool NProblemIPOPT::eval_f(Index n, const Number* x, bool new_x, Number& obj_val
bool
NProblemIPOPT
::
eval_grad_f
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Number
*
grad_f
)
{
DEB_enter_func
;
problem_
->
eval_gradient
(
x
,
grad_f
);
return
true
;
...
...
@@ -267,6 +272,7 @@ bool NProblemIPOPT::eval_grad_f(Index n, const Number* x, bool new_x, Number* gr
bool
NProblemIPOPT
::
eval_g
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Index
m
,
Number
*
g
)
{
DEB_enter_func
;
// evaluate all constraint functions
for
(
int
i
=
0
;
i
<
m
;
++
i
)
g
[
i
]
=
constraints_
[
i
]
->
eval_constraint
(
x
);
...
...
@@ -512,6 +518,26 @@ void NProblemIPOPT::finalize_solution(SolverReturn status,
//-----------------------------------------------------------------------------
bool
NProblemIPOPT
::
intermediate_callback
(
Ipopt
::
AlgorithmMode
/*mode*/
,
Index
/*iter*/
,
Number
/*obj_value*/
,
Number
/*inf_pr*/
,
Number
/*inf_du*/
,
Number
/*mu*/
,
Number
/*d_norm*/
,
Number
/*regularization_size*/
,
Number
/*alpha_du*/
,
Number
/*alpha_pr*/
,
Index
/*ls_trials*/
,
const
IpoptData
*
/*ip_data*/
,
IpoptCalculatedQuantities
*
/*ip_cq*/
)
{
PROGRESS_TICK
;
return
true
;
}
//-----------------------------------------------------------------------------
bool
NProblemIPOPT
::
hessian_constant
()
const
{
return
hessian_constant_
;
...
...
@@ -542,6 +568,7 @@ bool NProblemIPOPT::jac_d_constant() const
bool
NProblemGmmIPOPT
::
get_nlp_info
(
Index
&
n
,
Index
&
m
,
Index
&
nnz_jac_g
,
Index
&
nnz_h_lag
,
IndexStyleEnum
&
index_style
)
{
DEB_enter_func
;
// number of variables
n
=
problem_
->
n_unknowns
();
...
...
@@ -633,6 +660,7 @@ bool NProblemGmmIPOPT::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
bool
NProblemGmmIPOPT
::
get_bounds_info
(
Index
n
,
Number
*
x_l
,
Number
*
x_u
,
Index
m
,
Number
*
g_l
,
Number
*
g_u
)
{
DEB_enter_func
;
// first clear all variable bounds
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
...
...
@@ -668,6 +696,7 @@ bool NProblemGmmIPOPT::get_starting_point(Index n, bool init_x, Number* x,
Index
m
,
bool
init_lambda
,
Number
*
lambda
)
{
DEB_enter_func
;
// get initial value of problem instance
problem_
->
initial_x
(
x
);
...
...
@@ -680,6 +709,7 @@ bool NProblemGmmIPOPT::get_starting_point(Index n, bool init_x, Number* x,
bool
NProblemGmmIPOPT
::
eval_f
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Number
&
obj_value
)
{
DEB_enter_func
;
// return the value of the objective function
obj_value
=
problem_
->
eval_f
(
x
);
return
true
;
...
...
@@ -691,6 +721,7 @@ bool NProblemGmmIPOPT::eval_f(Index n, const Number* x, bool new_x, Number& obj_
bool
NProblemGmmIPOPT
::
eval_grad_f
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Number
*
grad_f
)
{
DEB_enter_func
;
problem_
->
eval_gradient
(
x
,
grad_f
);
return
true
;
...
...
@@ -702,6 +733,7 @@ bool NProblemGmmIPOPT::eval_grad_f(Index n, const Number* x, bool new_x, Number*
bool
NProblemGmmIPOPT
::
eval_g
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Index
m
,
Number
*
g
)
{
DEB_enter_func
;
// evaluate all constraint functions
for
(
int
i
=
0
;
i
<
m
;
++
i
)
g
[
i
]
=
constraints_
[
i
]
->
eval_constraint
(
x
);
...
...
@@ -840,10 +872,27 @@ void NProblemGmmIPOPT::finalize_solution(SolverReturn status,
const
IpoptData
*
ip_data
,
IpoptCalculatedQuantities
*
ip_cq
)
{
DEB_enter_func
;
// problem knows what to do
problem_
->
store_result
(
x
);
}
bool
NProblemGmmIPOPT
::
intermediate_callback
(
Ipopt
::
AlgorithmMode
/*mode*/
,
Index
/*iter*/
,
Number
/*obj_value*/
,
Number
/*inf_pr*/
,
Number
/*inf_du*/
,
Number
/*mu*/
,
Number
/*d_norm*/
,
Number
/*regularization_size*/
,
Number
/*alpha_du*/
,
Number
/*alpha_pr*/
,
Index
/*ls_trials*/
,
const
IpoptData
*
/*ip_data*/
,
IpoptCalculatedQuantities
*
/*ip_cq*/
)
{
PROGRESS_TICK
;
return
true
;
}
//=============================================================================
}
// namespace COMISO
...
...
Solver/ConstrainedSolverT.cc
View file @
15b5154a
This diff is collapsed.
Click to expand it.
Solver/GMM_ToolsT.cc
View file @
15b5154a
...
...
@@ -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 @
15b5154a
...
...
@@ -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
);
}
...
...
cmake/CoMISoExample.cmake
View file @
15b5154a
...
...
@@ -123,6 +123,14 @@ if (GUROBI_FOUND )
list
(
APPEND COMISO_LINK_LIBRARIES
${
GUROBI_LIBRARIES
}
)
endif
()
if
(
MOSEK_FOUND
)
list
(
APPEND COMISO_INCLUDE_DIRECTORIES
${
MOSEK_INCLUDE_DIRS
}
)
list
(
APPEND COMISO_LINK_LIBRARIES
${
MOSEK_LIBRARIES
}
)
list
(
APPEND COMISO_LINK_DIRECTORIES
${
MOSEK_LIBRARY_DIR
}
)
endif
()