| 1 | package de.uka.ipd.sdq.dsexplore.analysis.lqn; |
| 2 | |
| 3 | import org.eclipse.core.runtime.CoreException; |
| 4 | import org.opt4j.core.Criterion; |
| 5 | |
| 6 | import LqnCore.LqnModelType; |
| 7 | import de.uka.ipd.sdq.dsexplore.analysis.AnalysisFailedException; |
| 8 | import de.uka.ipd.sdq.dsexplore.analysis.IAnalysisResult; |
| 9 | import de.uka.ipd.sdq.pcmsolver.models.PCMInstance; |
| 10 | import de.uka.ipd.sdq.pcmsolver.runconfig.MessageStrings; |
| 11 | |
| 12 | /** |
| 13 | * Starts a LQN Solver Analysis for the design space exploration. |
| 14 | * |
| 15 | * @author pmerkle |
| 16 | * |
| 17 | */ |
| 18 | public class LQNSolverAnalysis extends AbstractLQNAnalysis { |
| 19 | |
| 20 | boolean hasConverged = true; |
| 21 | |
| 22 | /** |
| 23 | * try to handle the exception or throw it back. |
| 24 | * @param e |
| 25 | * @return |
| 26 | */ |
| 27 | @Override |
| 28 | protected IAnalysisResult handleException(RuntimeException e, PCMInstance pcm) { |
| 29 | if (e.getMessage() != null && |
| 30 | (e.getMessage().contains("exited with 1: The model failed to converge.")) |
| 31 | || (e.getMessage().contains("Open arrival rate of ") |
| 32 | && e.getMessage().contains("is too high."))){ |
| 33 | hasConverged = false; |
| 34 | return new LQNNotConvergedResult(pcm); |
| 35 | // } else if (e.getMessage() != null && e.getMessage().contains("invalid input")){ |
| 36 | // String inputFileName = Pcm2LqnStrategy.FILENAME_INPUT_XML; |
| 37 | // copyfile(inputFileName, inputFileName+"-invalidInput"+iteration); |
| 38 | // throw e; |
| 39 | // } else if (e.getMessage() != null && e.getMessage().contains(" returned an unrecognised exit value")){ |
| 40 | // String inputFileName = Pcm2LqnStrategy.FILENAME_INPUT_XML; |
| 41 | // copyfile(inputFileName, inputFileName+"-unrecognizedExit"+iteration); |
| 42 | // throw e; |
| 43 | } else { |
| 44 | throw e; |
| 45 | } |
| 46 | |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | protected String getSolverMessageString() { |
| 51 | return MessageStrings.LQNS_SOLVER; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public boolean hasStatisticResults() throws CoreException { |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | protected ILQNResult retrieveResult(PCMInstance pcm, |
| 61 | LqnModelType model, Criterion criterion) throws AnalysisFailedException { |
| 62 | ILQNResult result; |
| 63 | if (hasConverged){ |
| 64 | result = new LQNSolverAnalysisResult(model, pcm, criterion, this.criterionToAspect, this.lQNQualityAttribute); |
| 65 | } else { |
| 66 | result = new LQNNotConvergedResult(pcm); |
| 67 | hasConverged = true; |
| 68 | } |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | @Override |
| 74 | public boolean hasObjectivePerUsageScenario() throws CoreException { |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | |
| 80 | } |