You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

strategyService.go 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package algo
  13. type strategyService interface {
  14. computeMaxScore() (*Task, error)
  15. }
  16. func ScheduleWithFullCollaboration(strategyService strategyService, ProviderList []*Provider) (*Task, error) {
  17. task, err := strategyService.computeMaxScore()
  18. if err != nil {
  19. return nil, err
  20. }
  21. //计算任务i的resourcePerTask属性
  22. for i, _ := range ProviderList {
  23. tasksolu := task.MaxscoreStrategy.Tasksolution[i] // 第j个提供商分到的任务数
  24. resourcesolu := task.MaxscoreStrategy.Resourcesolution[0][i] // 第j个提供商分到的资源数
  25. // 在第j个云提供商处声明一个长度为资源数的链表
  26. resourcePerTaskPerProviders := make([]int, resourcesolu)
  27. if tasksolu > 0 {
  28. for tasksolu > 0 {
  29. for j := 0; j < resourcesolu; j++ {
  30. resourcePerTaskPerProviders[j] += 1
  31. tasksolu -= 1
  32. }
  33. }
  34. } else if tasksolu == 0 {
  35. resourcePerTaskPerProviders = []int{0}
  36. }
  37. task.ResourcePerTask = append(task.ResourcePerTask, resourcePerTaskPerProviders)
  38. }
  39. return task, nil
  40. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.