I am new to stackoverflow and I wonder if there is a suitable method/algorithm to solve my example problems in order to generate a desired solution that respect some conditions of the problems. Here is my json file(example1.json) as you can find from here: https://gitlab.com/Schrodinger168/practice/-/blob/master/example1.json
I will explain the csv file and what I want to generate as below:
For Ressources there are for example Ressources_X that X here can be a value from 1 to 9. All Ressource_X have their min and max values that needed to be respect as the final solution(will say below) cannot smaller than min and bigger than max for each day of all the Ressources_X.
For Seasons there are winter, summer, is… and each number correspond in those seasons refer to the day for example winter defines from day 1 to day 13 and the other seasons mean the same.
For Interventions: are tasks have to be planned. There are Intervention_X with corresponding workload containing Ressources_X that they have to use. Delta is the duration of the Intervention_X for example we can see in Intervention_625 as the first value(day 1) in the Delta list is 1.0 it means that if the Intervention_625 starts at day 1 it needs to finish in the same day(day 1) because its Delta value for day 1 is 1.0 and so on… Each Intervention_X has their own tmax for example Intervention_625 has tmax equal to 17 it means that it can be start between day 1 and day 17 as we wish to generate and the other tmax of other Intervention_X means the same.
For Exclusion there are some exceptions for example:
"E141["Intervention_315","Intervention_456","summer"] It means that Intervention_315 and Intervention_456 cannot start at the same day during the summer days(start at different days during the summer is ok) and the others mean the same.
T is the total duration here T = 17 it means that the duration of the overall work is 17 days
The solution I want to generate is the name of interventions and the starting day (tx,ty..) of each of those interventions for example:
and so on… until all the Interventions have been used as they will use for only one time.
And the solution will make sure that it respects the conditions of using the Ressources (min, max) for each day, Exclusion, and the finish date can be T + 1 for maximum.
Here is my code to access to each nodes and values of my json file if needed:
class access_json: def __init__(self): self._resources = dict() self._seasons = dict() self._interventions = dict() self._exclusions = dict() self._NRESOURCES = 0 self._NINTERVENTIONS = 0 self._list_resources = list() self._list_interventions = list() self._T = 0 def loadjson(self, fpath: str): js = dict() with open(fpath, 'r') as f: js = json.load(f) self._resources = js["Resources"] self._NRESOURCES = len(self._resources) self._list_resources = list(self._resources.keys()) self._seasons = js["Seasons"] self._interventions = js["Interventions"] self._NINTERVENTIONS = len(self._interventions) self._list_interventions = list(self._interventions.keys()) self._exclusions = js["Exclusions"] self._T = js["T"]
To solve the problems I try to use the permutation to exchange and replace those interventions in each day but it seems so long to do like that and did not generate the solution. Any help with codes, recommendation for how to apply the algorithm to solve this problem would be much appreciated. Thank you before hand!