make_cbg.m 1.6 KB

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