Beispiel #1
0
        public void CheckIfTreeWithFiltersCanBeDeserialized()
        {
            var root = new AndNode();

            root.AddChild(new ValueNode <int>("a", new IntegerDomain()));
            root.AddChild(new ValueNode <int>("b", new IntegerDomain()));
            var tree = new ParameterTree(root);

            tree.AddParameterReplacementDefinition("a", 42, "dummy", 1337);
            tree.AddParameterReplacementDefinition("b", 42, "dummy2", 1337);
            tree.AddParameterReplacementDefinition("a", 43, "dummy", 1338);

            var serializer = new Hyperion.Serializer();
            var treeStream = new MemoryStream();

            serializer.Serialize(tree, treeStream);
            var streamCopy   = new MemoryStream(treeStream.GetBuffer());
            var restoredTree = serializer.Deserialize <ParameterTree>(streamCopy);

            Assert.NotNull(restoredTree);
            var originalNodes = tree.GetParameters().ToList();
            var restoredNodes = restoredTree.GetParameters().ToList();

            Assert.Equal(originalNodes.Count, restoredNodes.Count);
            for (var i = 0; i < originalNodes.Count; i++)
            {
                var expectedNode = originalNodes[i];
                var restoredNode = restoredNodes[i];
                // It'd be too tedious to conduct a deeper comparison. Let's just assume that Nodes are correct when Name + DomainSize match.
                Assert.True(expectedNode.Identifier == restoredNode.Identifier, "Nodes were deserialized in wrong order.");
                Assert.Equal(expectedNode.Domain.DomainSize, restoredNode.Domain.DomainSize);
            }

            Assert.True(restoredTree.IsIndicatorParameterAndValueCombinationDefined("a", 42));
            Assert.True(restoredTree.IsIndicatorParameterAndValueCombinationDefined("b", 42));
            Assert.True(restoredTree.IsIndicatorParameterAndValueCombinationDefined("a", 43));
        }
Beispiel #2
0
 private static void AddAllActiveParameterWrappers(ParameterTree parameterTree)
 {
     parameterTree.AddParameterReplacementDefinition("bcamaxeffActive", false, "bcamaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("bcaminuseActive", false, "bcaminuse", 0, true);
     parameterTree.AddParameterReplacementDefinition("bkwdocclimActive", false, "bkwdocclim", 0, true);
     parameterTree.AddParameterReplacementDefinition("blkboostvlimActive", false, "blkboostvlim", 0, true);
     parameterTree.AddParameterReplacementDefinition("blkmaxeffActive", "unlimited", "blkmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("blkmaxeffActive", "disabled", "blkmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("blkmineffActive", false, "blkmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardmaxeffActive", "unlimited", "cardmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("cardmaxeffActive", "disabled", "cardmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardmaxlenActive", false, "cardmaxlen", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardmineffActive", false, "cardmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardminlenActive", false, "cardminlen", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardocclim1Active", false, "cardocclim1", 0, true);
     parameterTree.AddParameterReplacementDefinition("cardocclim2Active", false, "cardocclim2", 0, true);
     parameterTree.AddParameterReplacementDefinition("cce2waitActive", false, "cce2wait", 0, true);
     parameterTree.AddParameterReplacementDefinition("cce3waitActive", false, "cce3wait", 0, true);
     parameterTree.AddParameterReplacementDefinition("cceboostvlimActive", false, "cceboostvlim", 0, true);
     parameterTree.AddParameterReplacementDefinition("ccemaxeffActive", "unlimited", "ccemaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("ccemaxeffActive", "disabled", "ccemaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("ccemaxroundActive", false, "ccemaxround", 0, true);
     parameterTree.AddParameterReplacementDefinition("ccemineffActive", false, "ccemineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("decolimActive", false, "decolim", 0, true);
     parameterTree.AddParameterReplacementDefinition("elmaxeffActive", "unlimited", "elmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("elmaxeffActive", "disabled", "elmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("elmineffActive", false, "elmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("elmlitslimActive", false, "elmlitslim", 0, true);
     parameterTree.AddParameterReplacementDefinition("gaussmaxeffActive", "unlimited", "gaussmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("gaussmaxeffActive", "disabled", "gaussmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("gaussmineffActive", false, "gaussmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("locsActive", "unlimited", "locs", -1, true);
     parameterTree.AddParameterReplacementDefinition("locsActive", "disabled", "locs", 0, true);
     parameterTree.AddParameterReplacementDefinition("locsclimActive", false, "locsclim", 0, true);
     parameterTree.AddParameterReplacementDefinition("locsmaxeffActive", false, "locsmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("locsmineffActive", false, "locsmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("minlocalgluelimActive", false, "minlocalgluelim", 0, true);
     parameterTree.AddParameterReplacementDefinition("minlocalsizelimActive", false, "minlocalsizelim", 0, true);
     parameterTree.AddParameterReplacementDefinition("minrecgluelimActive", false, "minrecgluelim", 0, true);
     parameterTree.AddParameterReplacementDefinition("minrecsizelimActive", false, "minrecsizelim", 0, true);
     parameterTree.AddParameterReplacementDefinition("phaseluckmaxroundActive", false, "phaseluckmaxround", 0, true);
     parameterTree.AddParameterReplacementDefinition("plimActive", "unlimited", "plim", -1, true);
     parameterTree.AddParameterReplacementDefinition("plimActive", "disabled", "plim", 0, true);
     parameterTree.AddParameterReplacementDefinition("prbasicmaxeffActive", "unlimited", "prbasicmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("prbasicmaxeffActive", "disabled", "prbasicmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("prbasicmineffActive", false, "prbasicmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("prbsimplemaxeffActive", "unlimited", "prbsimplemaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("prbsimplemaxeffActive", "disabled", "prbsimplemaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("prbsimplemineffActive", false, "prbsimplemineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("redclsglueActive", false, "redclsglue", 0, true);
     parameterTree.AddParameterReplacementDefinition("redclsizeActive", false, "redclsize", 0, true);
     parameterTree.AddParameterReplacementDefinition("redclsmaxlrgActive", false, "redclsmaxlrg", 0, true);
     parameterTree.AddParameterReplacementDefinition("redclsmaxpropsActive", false, "redclsmaxprops", 0, true);
     parameterTree.AddParameterReplacementDefinition("restartblockboundActive", false, "restartblockbound", 0, true);
     parameterTree.AddParameterReplacementDefinition("retireminActive", false, "retiremin", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpcintdelayActive", false, "simpcintdelay", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpcintmaxhardActive", "unlimited", "simpcintmaxhard", -1, true);
     parameterTree.AddParameterReplacementDefinition("simpcintmaxhardActive", "disabled", "simpcintmaxhard", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpcintmaxsoftActive", "unlimited", "simpcintmaxsoft", -1, true);
     parameterTree.AddParameterReplacementDefinition("simpcintmaxsoftActive", "disabled", "simpcintmaxsoft", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpincdelmaxminActive", false, "simpincdelmaxmin", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpinitdelayActive", false, "simpinitdelay", 0, true);
     parameterTree.AddParameterReplacementDefinition("simpvarlimActive", false, "simpvarlim", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepforgiveActive", false, "sweepforgive", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepmaxdecActive", false, "sweepmaxdec", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepmaxeffActive", "unlimited", "sweepmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("sweepmaxeffActive", "disabled", "sweepmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepmaxroundActive", "unlimited", "sweepmaxround", -1, true);
     parameterTree.AddParameterReplacementDefinition("sweepmaxroundActive", "disabled", "sweepmaxround", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepmindecActive", false, "sweepmindec", 0, true);
     parameterTree.AddParameterReplacementDefinition("sweepmineffActive", false, "sweepmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("synclsglueActive", false, "synclsglue", 0, true);
     parameterTree.AddParameterReplacementDefinition("synclslenActive", false, "synclslen", 0, true);
     parameterTree.AddParameterReplacementDefinition("trdmaxeffActive", "unlimited", "trdmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("trdmaxeffActive", "disabled", "trdmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("trdmineffActive", false, "trdmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("treelookmaxeffActive", "unlimited", "treelookmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("treelookmaxeffActive", "disabled", "treelookmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("treelookmineffActive", false, "treelookmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("trnrmaxeffActive", "unlimited", "trnrmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("trnrmaxeffActive", "disabled", "trnrmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("trnrmineffActive", false, "trnrmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("unhdlnprActive", false, "unhdlnpr", 0, true);
     parameterTree.AddParameterReplacementDefinition("unhdmaxeffActive", "unlimited", "unhdmaxeff", -1, true);
     parameterTree.AddParameterReplacementDefinition("unhdmaxeffActive", "disabled", "unhdmaxeff", 0, true);
     parameterTree.AddParameterReplacementDefinition("unhdmineffActive", false, "unhdmineff", 0, true);
     parameterTree.AddParameterReplacementDefinition("waitmaxActive", "unlimited", "waitmax", -1, true);
     parameterTree.AddParameterReplacementDefinition("waitmaxActive", "disabled", "waitmax", 0, true);
 }
Beispiel #3
0
 /// <summary>
 /// Adds all required parameter replacements to the <paramref name="parameterTree"/>.
 /// </summary>
 /// <param name="parameterTree">
 /// The parameter tree.
 /// </param>
 private static void AddAllIndicatorParameterWrappers(ParameterTree parameterTree)
 {
     parameterTree.AddParameterReplacementDefinition("AggFillIndicator", "off", GRB.IntParam.AggFill.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("AggFillIndicator", "default", GRB.IntParam.AggFill.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("CutPassesIndicator", "off", GRB.IntParam.CutPasses.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("CutPassesIndicator", "default", GRB.IntParam.CutPasses.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("DegenMovesIndicator", "off", GRB.IntParam.DegenMoves.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("DegenMovesIndicator", "default", GRB.IntParam.DegenMoves.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("GomoryPassesIndicator", "off", GRB.IntParam.GomoryPasses.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("GomoryPassesIndicator", "default", GRB.IntParam.GomoryPasses.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("MinRelNodesIndicator", "off", GRB.IntParam.MinRelNodes.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("MinRelNodesIndicator", "default", GRB.IntParam.MinRelNodes.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("PrePassesIndicator", "off", GRB.IntParam.PrePasses.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("PrePassesIndicator", "default", GRB.IntParam.PrePasses.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("PumpPassesIndicator", "off", GRB.IntParam.PumpPasses.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("PumpPassesIndicator", "default", GRB.IntParam.PumpPasses.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("RinsIndicator", "off", GRB.IntParam.RINS.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("RinsIndicator", "default", GRB.IntParam.RINS.ToString(), -1, true);
     parameterTree.AddParameterReplacementDefinition("ZeroObjNodesIndicator", "off", GRB.IntParam.ZeroObjNodes.ToString(), 0, true);
     parameterTree.AddParameterReplacementDefinition("ZeroObjNodesIndicator", "default", GRB.IntParam.ZeroObjNodes.ToString(), -1, true);
 }