public LtmcToDtmc(LabeledTransitionMarkovChain ltmc) { var stopwatch = new Stopwatch(); stopwatch.Start(); Console.Out.WriteLine("Starting to convert labeled transition Markov chain to Markov chain"); Console.Out.WriteLine($"Ltmc: States {ltmc.SourceStates.Count}, Transitions {ltmc.Transitions}"); CreateStates(ltmc); var modelCapacity = new ModelCapacityByModelSize(States, ltmc.Transitions * 8L); MarkovChain = new DiscreteTimeMarkovChain(modelCapacity); MarkovChain.StateFormulaLabels = ltmc.StateFormulaLabels; SetStateLabeling(); ConvertInitialStates(ltmc); ConvertTransitions(ltmc); stopwatch.Stop(); Console.Out.WriteLine($"Completed transformation in {stopwatch.Elapsed}"); Console.Out.WriteLine($"Mc: States {MarkovChain.States}, Transitions {MarkovChain.Transitions}"); }
public NmdpToMdpByFlattening(NestedMarkovDecisionProcess nmdp) : base(nmdp) { var stopwatch = new Stopwatch(); stopwatch.Start(); Console.Out.WriteLine("Starting to convert Nested Markov Decision Process to Markov Decision Process"); Console.Out.WriteLine($"Nmdp: States {nmdp.States}, ContinuationGraphSize {nmdp.ContinuationGraphSize}"); var modelCapacity = new ModelCapacityByModelSize(nmdp.States, nmdp.ContinuationGraphSize * 8L); MarkovDecisionProcess = new MarkovDecisionProcess(modelCapacity); MarkovDecisionProcess.StateFormulaLabels = nmdp.StateFormulaLabels; CopyStateLabeling(); ConvertInitialTransitions(); ConvertStateTransitions(); stopwatch.Stop(); _nmdp = null; Console.Out.WriteLine($"Completed transformation in {stopwatch.Elapsed}"); Console.Out.WriteLine($"Mdp: States {MarkovDecisionProcess.States}, Transitions {MarkovDecisionProcess.Transitions}"); }
public LtmdpToNmdp(LabeledTransitionMarkovDecisionProcess ltmdp) { var stopwatch = new Stopwatch(); stopwatch.Start(); Console.Out.WriteLine("Starting to convert labeled transition Markov Decision Process to Nested Markov Decision Process"); Console.Out.WriteLine($"Ltmdp: States {ltmdp.SourceStates.Count}, TransitionTargets {ltmdp.TransitionTargets}, ContinuationGraphSize {ltmdp.ContinuationGraphSize}"); _ltmdp = ltmdp; CreateStates(); var modelCapacity = new ModelCapacityByModelSize(MdpStates, ltmdp.ContinuationGraphSize * 8L); NestedMarkovDecisionProcess = new NestedMarkovDecisionProcess(modelCapacity); NestedMarkovDecisionProcess.StateFormulaLabels = ltmdp.StateFormulaLabels; SetStateLabeling(); ConvertInitialStates(); ConvertTransitions(); stopwatch.Stop(); _ltmdp = null; Console.Out.WriteLine($"Completed transformation in {stopwatch.Elapsed}"); Console.Out.WriteLine($"Nmdp: States {NestedMarkovDecisionProcess.States}, ContinuationGraphSize {NestedMarkovDecisionProcess.ContinuationGraphSize}"); }
public NmdpToMdpByNewStates(NestedMarkovDecisionProcess nmdp, TextWriter output = null, bool makeConstantDistanceBetweenStates = true) : base(nmdp) { _output = output ?? Console.Out; _makeConstantDistanceBetweenStates = makeConstantDistanceBetweenStates; var stopwatch = new Stopwatch(); stopwatch.Start(); _output.WriteLine("Starting to convert Nested Markov Decision Process to Markov Decision Process"); _output.WriteLine($"Nmdp: States {nmdp.States}, ContinuationGraphSize {nmdp.ContinuationGraphSize}"); var newNumberOfStates = nmdp.ContinuationGraphSize; var newNumberOfTransitions = nmdp.ContinuationGraphSize; if (_makeConstantDistanceBetweenStates) { newNumberOfStates = 30 * newNumberOfStates; newNumberOfTransitions = 30 * newNumberOfTransitions; } var modelCapacity = new ModelCapacityByModelSize(newNumberOfStates, newNumberOfTransitions); MarkovDecisionProcess = new MarkovDecisionProcess(modelCapacity); _nmdpStates = _nmdp.States; CalculateMaxDistanceBetweenStates(); CreateArtificalStateFormula(); ConvertInitialTransitions(); ConvertStateTransitions(); AddPaddingStatesInMdp(); SetStateLabelings(); stopwatch.Stop(); _nmdp = null; _output.WriteLine($"Completed transformation in {stopwatch.Elapsed}"); _output.WriteLine($"Mdp: States {MarkovDecisionProcess.States}, Transitions {MarkovDecisionProcess.Transitions}"); }