| Quintiq file version 2.0 | 
| #parent: #root | 
| Function CalcAvailableCapacityRatio | 
| { | 
|   Description: 'calculates a value between 0 and 1 corresponding to how much the campaign and period overlap' | 
|   TextBody: | 
|   [* | 
|     // oceaned Feb-10-2016 (created) | 
|      | 
|     value := 0.0; | 
|     period := this.UnitPeriod().Period_MP(); | 
|     duration := period.Duration().HoursAsReal(); | 
|      | 
|     if( duration > 0 ) | 
|     { | 
|       start := maxvalue( period.Start(), this.Transition_MP().Start() ); | 
|       end := minvalue( period.End(), this.Transition_MP().End() ); | 
|      | 
|       value := ( end - start ).HoursAsReal() / duration; | 
|       value := maxvalue( value, 0.0 ); | 
|     } | 
|      | 
|     this.AvailableCapacityRatio( value ); | 
|   *] | 
| } |