make_ese.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. function ese = make_ese(system,sorter_on)
  2. global mtt_environment
  3. if nargin<2
  4. sorter_on = 1 ;
  5. end
  6. switch class(system)
  7. case 'char',
  8. input = 'spec' ;
  9. case 'struct',
  10. if isfield(system,'representation')
  11. input = system.representation ;
  12. end
  13. end
  14. start_time = mttGetTime ;
  15. abg = [] ;
  16. cbg = [] ;
  17. ese = [] ;
  18. if strcmp(input,'spec')
  19. mttWriteNewLine ;
  20. mttNotify('Making "abg" representation') ;
  21. mttWriteNewLine ;
  22. if isempty(mtt_environment)
  23. mttNotify('...WARNING: No "env" definition => all domain references will be ignored') ;
  24. mttWriteNewLine ;
  25. mttNotify(' => paths will not be recognised') ;
  26. mttWriteNewLine ;
  27. end
  28. abg = mttCreateAcausalBondgraph(system) ;
  29. input = 'abg' ;
  30. end
  31. if strcmp(input,'abg')
  32. if isempty(abg)
  33. abg = system ;
  34. end
  35. mttWriteNewLine ;
  36. mttNotify('Transforming from "abg" to "cbg"') ;
  37. mttWriteNewLine ;
  38. cbg = mttCreateCausalBondgraph(abg) ;
  39. input = 'cbg' ;
  40. end
  41. if strcmp(input,'cbg')
  42. if isempty(cbg)
  43. cbg = system ;
  44. end
  45. mttWriteNewLine ;
  46. mttNotify('Transforming from "cbg" to "ese"') ;
  47. mttWriteNewLine ;
  48. ese = mttCreateElementaryEquations(cbg,sorter_on) ;
  49. input = 'ese' ;
  50. end
  51. mttAssert(strcmp(input,'ese'),'Input representation not recognised') ;
  52. if isempty(ese)
  53. mttWriteNewLine ;
  54. mttNotify('Making "ese" representation') ;
  55. mttWriteNewLine ;
  56. mttNotify('Input already defined as a "ese": copying to Output') ;
  57. mttWriteNewLine ;
  58. mttWriteNewLine ;
  59. ese = system ;
  60. end
  61. elapsed_time = mttElapseTime(start_time) ;
  62. cpu_utilisation = round(100*elapsed_time.cpu/elapsed_time.clock) ;
  63. mttWriteNewLine ;
  64. mttNotify(['Completed in ',num2str(elapsed_time.clock),' seconds']) ;
  65. mttNotify([' (',num2str(cpu_utilisation),'%% cpu)']) ;
  66. mttWriteNewLine ;
  67. mttWriteNewLine ;