Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IP
elsa
Commits
254f70e5
Commit
254f70e5
authored
Oct 11, 2021
by
Andi Braimllari
Committed by
Tobias Lasser
Oct 11, 2021
Browse files
SplittingProblem now supports different DomainDescriptors in data and regularization terms
parent
c154949a
Pipeline
#710105
passed with stages
in 23 minutes and 58 seconds
Changes
2
Pipelines
8
Hide whitespace changes
Inline
Side-by-side
elsa/problems/Problem.cpp
View file @
254f70e5
...
...
@@ -17,13 +17,6 @@ namespace elsa
if
(
_dataTerm
->
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
this
->
_currentSolution
.
getSize
())
throw
InvalidArgumentError
(
"Problem: domain of dataTerm and solution do not match"
);
for
(
auto
&
regTerm
:
_regTerms
)
{
if
(
dataTerm
.
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
regTerm
.
getFunctional
().
getDomainDescriptor
().
getNumberOfCoefficients
())
throw
InvalidArgumentError
(
"Problem: one of the reg terms' domain does not match the data term's"
);
}
}
template
<
typename
data_t
>
...
...
@@ -35,14 +28,6 @@ namespace elsa
_currentSolution
{
dataTerm
.
getDomainDescriptor
()},
_lipschitzConstant
{
lipschitzConstant
}
{
// sanity check
for
(
auto
&
regTerm
:
_regTerms
)
{
if
(
dataTerm
.
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
regTerm
.
getFunctional
().
getDomainDescriptor
().
getNumberOfCoefficients
())
throw
InvalidArgumentError
(
"Problem: one of the reg terms' domain does not match the data term's"
);
}
_currentSolution
=
0
;
}
...
...
@@ -60,11 +45,6 @@ namespace elsa
if
(
_dataTerm
->
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
this
->
_currentSolution
.
getSize
())
throw
InvalidArgumentError
(
"Problem: domain of dataTerm and solution do not match"
);
if
(
dataTerm
.
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
regTerm
.
getFunctional
().
getDomainDescriptor
().
getNumberOfCoefficients
())
throw
InvalidArgumentError
(
"Problem: one of the reg terms' domain does not match the data term's"
);
}
template
<
typename
data_t
>
...
...
@@ -76,12 +56,6 @@ namespace elsa
_currentSolution
{
dataTerm
.
getDomainDescriptor
(),
defaultHandlerType
},
_lipschitzConstant
{
lipschitzConstant
}
{
// sanity check
if
(
dataTerm
.
getDomainDescriptor
().
getNumberOfCoefficients
()
!=
regTerm
.
getFunctional
().
getDomainDescriptor
().
getNumberOfCoefficients
())
throw
InvalidArgumentError
(
"Problem: one of the reg terms' domain does not match the data term's"
);
_currentSolution
=
0
;
}
...
...
elsa/problems/tests/test_Problem.cpp
View file @
254f70e5
...
...
@@ -221,6 +221,25 @@ TEST_CASE("Problem: Testing with one regularization term")
REQUIRE_UNARY
(
checkApproxEq
(
prob
.
getLipschitzConstant
(
100
),
1.0
f
+
weight
));
}
}
WHEN
(
"given a different data descriptor and another regularization term with a different "
"domain descriptor"
)
{
// three-dimensional data descriptor
IndexVector_t
otherNumCoeff
(
3
);
otherNumCoeff
<<
15
,
38
,
22
;
VolumeDescriptor
otherDD
(
otherNumCoeff
);
// l2 norm regularization term
L2NormPow2
otherRegFunc
(
otherDD
);
RegularizationTerm
otherRegTerm
(
weight
,
otherRegFunc
);
THEN
(
"no exception is thrown when setting up a problem with different domain "
"descriptors"
)
{
REQUIRE_NOTHROW
(
Problem
{
func
,
otherRegTerm
});
}
}
}
}
...
...
@@ -335,6 +354,34 @@ TEST_CASE("Problem: Testing with several regularization terms")
checkApproxEq
(
prob
.
getLipschitzConstant
(
100
),
1.0
f
+
weight1
+
weight2
));
}
}
WHEN
(
"given two different data descriptors and two regularization terms with a different "
"domain descriptor"
)
{
// three-dimensional data descriptor
IndexVector_t
otherNumCoeff
(
3
);
otherNumCoeff
<<
15
,
38
,
22
;
VolumeDescriptor
otherDD
(
otherNumCoeff
);
// four-dimensional data descriptor
IndexVector_t
anotherNumCoeff
(
4
);
anotherNumCoeff
<<
7
,
9
,
21
,
17
;
VolumeDescriptor
anotherDD
(
anotherNumCoeff
);
// l2 norm regularization term
L2NormPow2
otherRegFunc
(
otherDD
);
RegularizationTerm
otherRegTerm
(
weight1
,
otherRegFunc
);
// l2 norm regularization term
L2NormPow2
anotherRegFunc
(
anotherDD
);
RegularizationTerm
anotherRegTerm
(
weight2
,
anotherRegFunc
);
THEN
(
"no exception is thrown when setting up a problem with different domain "
"descriptors"
)
{
REQUIRE_NOTHROW
(
Problem
{
func
,
std
::
vector
{
otherRegTerm
,
anotherRegTerm
}});
}
}
}
}
...
...
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