add sets up
This commit is contained in:
		@@ -55,7 +55,7 @@ func (wf *Graph) IsWorkflow(item GraphItem) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, processings []*resources.ProcessingResource, resource resources.ResourceInterface,
 | 
			
		||||
	f func(GraphItem) resources.ResourceInterface, request *tools.APIRequest, buyingStrategy int, pricingStrategy int) (float64, float64) {
 | 
			
		||||
	f func(GraphItem) resources.ResourceInterface, request *tools.APIRequest) (float64, float64) {
 | 
			
		||||
	nearestStart := float64(10000000000)
 | 
			
		||||
	oneIsInfinite := false
 | 
			
		||||
	longestDuration := float64(0)
 | 
			
		||||
@@ -67,7 +67,7 @@ func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, proce
 | 
			
		||||
			} else if link.Source.ID == processing.GetID() && f(g.Items[link.Source.ID]) != nil && f(g.Items[link.Source.ID]).GetID() == resource.GetID() { // if the source is the processing and the destination is not a compute
 | 
			
		||||
				source = link.Destination.ID
 | 
			
		||||
			}
 | 
			
		||||
			priced := processing.ConvertToPricedResource(tools.PROCESSING_RESOURCE, request, buyingStrategy, pricingStrategy)
 | 
			
		||||
			priced := processing.ConvertToPricedResource(tools.PROCESSING_RESOURCE, request)
 | 
			
		||||
			if source != "" {
 | 
			
		||||
				if priced.GetLocationStart() != nil {
 | 
			
		||||
					near := float64(priced.GetLocationStart().Sub(start).Seconds())
 | 
			
		||||
@@ -96,7 +96,7 @@ func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, proce
 | 
			
		||||
/*
 | 
			
		||||
* GetAverageTimeBeforeStart is a function that returns the average time before the start of a processing
 | 
			
		||||
 */
 | 
			
		||||
func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingID string, request *tools.APIRequest, buyingStrategy int, pricingStrategy int) float64 {
 | 
			
		||||
func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingID string, request *tools.APIRequest) float64 {
 | 
			
		||||
	currents := []float64{}        // list of current time
 | 
			
		||||
	for _, link := range g.Links { // for each link
 | 
			
		||||
		var source string                                                                     // source is the source of the link
 | 
			
		||||
@@ -112,13 +112,13 @@ func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingI
 | 
			
		||||
		if r == nil {                  // if item is nil, continue
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		priced := r.ConvertToPricedResource(dt, request, buyingStrategy, pricingStrategy)
 | 
			
		||||
		priced := r.ConvertToPricedResource(dt, request)
 | 
			
		||||
		current := priced.GetExplicitDurationInS() // get the explicit duration of the item
 | 
			
		||||
		if current < 0 {                           // if current is negative, its means that duration of a before could be infinite continue
 | 
			
		||||
			return current
 | 
			
		||||
		}
 | 
			
		||||
		current += g.GetAverageTimeProcessingBeforeStart(current, source, request, buyingStrategy, pricingStrategy) // get the average time before start of the source
 | 
			
		||||
		currents = append(currents, current)                                                                        // append the current to the currents
 | 
			
		||||
		current += g.GetAverageTimeProcessingBeforeStart(current, source, request) // get the average time before start of the source
 | 
			
		||||
		currents = append(currents, current)                                       // append the current to the currents
 | 
			
		||||
	}
 | 
			
		||||
	var max float64 // get the max time to wait dependancies to finish
 | 
			
		||||
	for _, current := range currents {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user