Commit 8560f1af authored by Roman Tolchenov's avatar Roman Tolchenov Committed by Anthony Lim
Browse files

Re #19115. Fixed the bug.

parent 56b43010
......@@ -205,9 +205,7 @@ std::string IFunction::asString() const {
}
// print the parameters
for (size_t i = 0; i < nParams(); i++) {
if (!isFixed(i)) {
ostr << ',' << parameterName(i) << '=' << getParameter(i);
}
ostr << ',' << parameterName(i) << '=' << getParameter(i);
}
// collect non-default constraints
......
......@@ -433,9 +433,9 @@ public:
void test_MultiDomainFunction_creation_moreComplex() {
const std::string fnString =
"composite=MultiDomainFunction,NumDeriv=true;(name=FunctionFactoryTest_"
"FunctA,a0=0,a1=0.5;name=FunctionFactoryTest_FunctB,b0=0.1,ties="
"FunctA,a0=0,a1=0.5;name=FunctionFactoryTest_FunctB,b0=0.1,b1=0.2,ties="
"(b1=0.2),$domains=i);(name=FunctionFactoryTest_FunctA,a0=0,a1=0.5;"
"name=FunctionFactoryTest_FunctB,b0=0.1,$domains=i);ties=(f1.f1."
"name=FunctionFactoryTest_FunctB,b0=0.1,b1=0.2,$domains=i);ties=(f1.f1."
"b1=f0.f1.b1)";
IFunction_sptr fun;
TS_ASSERT_THROWS_NOTHING(
......
......@@ -279,10 +279,9 @@ public:
icf.addTies("b2=b1,a2=a1/5");
icf.applyTies();
TS_ASSERT_EQUALS(
icf.asString(),
"name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,ties=(a2=a1/5,b2=b1)");
TS_ASSERT_EQUALS(icf.asString(), "name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,a2=2."
"2,b2=12,ties=(a2=a1/5,b2=b1)");
auto fun = FunctionFactory::Instance().createInitialized(icf.asString());
TS_ASSERT(fun);
......@@ -309,7 +308,7 @@ public:
TS_ASSERT_EQUALS(icf.asString(), "name=ImmutableCompositeFunctionTest_"
"FunctionWithTies,NumDeriv=false,a1=1,b1="
"2");
"2,a2=0.25,b2=1");
auto fun = FunctionFactory::Instance().createInitialized(icf.asString());
TS_ASSERT(fun);
......
......@@ -441,16 +441,31 @@ public:
}
void test_string_representation() {
const std::string expected =
"composite=MultiDomainFunction,NumDeriv=true;"
"name=MultiDomainFunctionTest_Function,A=0,B=1,$domains=i;"
"name=MultiDomainFunctionTest_Function,B=2,$domains=i;"
"name=MultiDomainFunctionTest_Function,B=3,$domains=i;ties=(f1.A="
"f0.A,f2.A=f0.A)";
const std::string expected = "composite=MultiDomainFunction,NumDeriv=true;"
"name=MultiDomainFunctionTest_Function,A=0,B="
"1,$domains=i;name=MultiDomainFunctionTest_"
"Function,A=0,B=2,$domains=i;name="
"MultiDomainFunctionTest_Function,A=0,B=3,$"
"domains=i;ties=(f1.A=f0.A,f2.A=f0.A)";
TS_ASSERT_EQUALS(multi.asString(), expected);
TS_ASSERT_EQUALS(multi.asString(), multi.clone()->asString());
}
void test_equivalent_functions() {
std::string ini =
"composite=MultiDomainFunction;"
"name=MultiDomainFunctionTest_Function,A=1,B=2,$domains=i;"
"name=MultiDomainFunctionTest_Function,A=3,B=4,$domains=i;ties=(f1.A="
"f0.B)";
auto mfun = boost::dynamic_pointer_cast<CompositeFunction>(
FunctionFactory::Instance().createInitialized(ini));
auto eqFuns = mfun->createEquivalentFunctions();
TS_ASSERT_EQUALS(eqFuns.size(), 2);
TS_ASSERT_EQUALS(eqFuns[0]->asString(), "name=MultiDomainFunctionTest_Function,A=1,B=2");
TS_ASSERT_EQUALS(eqFuns[1]->asString(), "name=MultiDomainFunctionTest_Function,A=2,B=4");
}
private:
MultiDomainFunction multi;
JointDomain domain;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment