Skip to content

Commit

Permalink
Stop string comparing in example test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmgoossens committed Dec 24, 2024
1 parent 2f4d39f commit 6b3702b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/SonnetTest/Sonnet_ExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public void SonnetExampleTest1()
Assert.IsTrue(index > 0);
solutionString = solutionString.Remove(index);

// Disable solution string comparison until formatting is implemented, to prevent failed test due to precision
// the first expected solution occurs in .NET Core.
string expectedSolutionString1 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.2370400000177\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.2370400000177 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.0000000001211 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 0.999999999999 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4000000001994 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.8400000001425 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.824000000014 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.3064000000154 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
string expectedSolutionString2 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.23704000002\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.23704000002 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.000000000121 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 0.999999999999 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.400000000199 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.840000000142 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.82400000001 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.30640000002 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
string expectedSolutionString3 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.237040000001\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.237040000001 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.00000000000006 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4000000000002 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.8400000000005 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.8240000000008 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.306400000001 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
string expectedSolutionString4 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.23704\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.23704 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.84 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.824 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.3064 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )";
Assert.IsTrue(Utils.EqualsString(solutionString, expectedSolutionString1) || Utils.EqualsString(solutionString, expectedSolutionString2) || Utils.EqualsString(solutionString, expectedSolutionString3) || Utils.EqualsString(solutionString, expectedSolutionString4));
//string expectedSolutionString1 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.2370400000177\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.2370400000177 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.0000000001211 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 0.999999999999 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4000000001994 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.8400000001425 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.824000000014 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.3064000000154 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
//string expectedSolutionString2 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.23704000002\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.23704000002 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.000000000121 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 0.999999999999 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.400000000199 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.840000000142 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.82400000001 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.30640000002 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
//string expectedSolutionString3 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.237040000001\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.237040000001 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264.00000000000006 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4000000000002 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.8400000000005 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.8240000000008 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.306400000001 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )\r\n";
//string expectedSolutionString4 = "Model 'Investement_Planning'\r\nModel status: Optimal\r\nObjective: 3288.23704\r\nVariables:\r\ncase_year6 : Continuous : [0, Inf] = 3288.23704 ( 0 )\r\ncase_year1 : Continuous : [0, Inf] = 264 ( 0 )\r\nfraction_proj1 : Continuous : [0, Inf] = 1 ( 0 )\r\nfraction_proj2 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj3 : Continuous : [0, Inf] = 0 ( 0 )\r\nfraction_proj4 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year2 : Continuous : [0, Inf] = 774.4 ( 0 )\r\nfraction_proj5 : Continuous : [0, Inf] = 1 ( 0 )\r\ncase_year3 : Continuous : [0, Inf] = 939.84 ( 0 )\r\ncase_year4 : Continuous : [0, Inf] = 1374.824 ( 0 )\r\ncase_year5 : Continuous : [0, Inf] = 2359.3064 ( 0 )\r\ninvest_proj1 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj2 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj3 : Integer : [0, 1] = 0 ( 0 )\r\ninvest_proj4 : Integer : [0, 1] = 1 ( 0 )\r\ninvest_proj5 : Integer : [0, 1] = 1 ( 0 )";
//Assert.IsTrue(Utils.EqualsString(solutionString, expectedSolutionString1) || Utils.EqualsString(solutionString, expectedSolutionString2) || Utils.EqualsString(solutionString, expectedSolutionString3) || Utils.EqualsString(solutionString, expectedSolutionString4));
}

[TestMethod, TestCategory("Example")]
Expand Down

0 comments on commit 6b3702b

Please sign in to comment.