| Paste number 51490: | Creating/using struct for storing data |
| Pasted by: | xp_prg |
| 10 months, 2 weeks ago | |
| #lispcafe | Context in IRC logs | |
| Paste contents: |
| :- export struct(task( name, % atom start, % integer variable duration, % integer need, % list of tasks use, % resource id (1..NRes, 0 if no resource needed) use_index % index of this task within its resource (integer > 0) )). get_bench(Name, Tasks, NRes, EndDate) :- jobshop(Name, _Comment, NJobs, NRes, Data), ( for(I,1,NJobs), count(Ascii,0'a,_), fromto(Tasks, Tasks3, Tasks0, [EndTask]), fromto(LastTasks, [LastTask|LastTasks0], LastTasks0, []), param(NRes,Data) do char_code(Letter, Ascii), ( for(J,1,NRes), fromto(Tasks3, [T|Tasks1], Tasks1, Tasks0), fromto([], PrevTask, [T], [LastTask]), param(I,Letter,Data) do concat_atom([Letter,J],TId), subscript(Data, [I,J], UsedResNr-Duration), RId is UsedResNr+1, % our resource ids are 1..NRes T = task{name:TId,use:RId,duration:Duration,need:PrevTask} ) ), % add a dummy end task after all last job tasks EndTask = task{name:end,start:EndDate,use:0,duration:0,need:LastTasks}. Data is being represented like this: % jobshop(Name, Comment, M, N, <Matrix of JobNr-Duration pairs>) jobshop(orb03, "deadlier 10x10 instance from Bruce Gamble (BRG1)", 10, 10, []([](0-96, 1-69, 2-25, 3-5, 4-55, 5-15, 6-88, 7-11, 8-17, 9-82), [](0-11, 1-48, 2-67, 3-38, 4-18, 7-24, 6-62, 5-92, 9-96, 8-81), [](2-67, 1-63, 0-93, 4-85, 3-25, 5-72, 6-51, 7-81, 8-58, 9-15), [](2-30, 1-35, 0-27, 4-82, 3-44, 7-92, 6-25, 5-49, 9-28, 8-77), [](1-53, 0-83, 4-73, 3-26, 2-77, 6-33, 5-92, 9-99, 8-38, 7-38), [](1-20, 0-44, 4-81, 3-88, 2-66, 6-70, 5-91, 9-37, 8-55, 7-96), [](1-21, 2-93, 4-22, 0-56, 3-34, 6-40, 7-53, 9-46, 5-29, 8-63), [](1-32, 2-63, 4-36, 0-26, 3-17, 5-85, 7-15, 8-55, 9-16, 6-82), [](0-73, 2-46, 3-89, 4-24, 1-99, 6-92, 7-7, 9-51, 5-19, 8-14), [](0-52, 2-20, 3-70, 4-98, 1-23, 5-15, 7-81, 8-71, 9-24, 6-81))).^M jobshop(orb04, "deadly 10x10 instance from Bruce Shepherd (BRS1)", 10, 10, []([](0-8, 1-10, 2-35, 3-44, 4-15, 5-92, 6-70, 7-89, 8-50, 9-12), [](0-63, 8-39, 3-80, 5-22, 2-88, 1-39, 9-85, 6-27, 7-74, 4-69), [](0-52, 6-22, 1-33, 3-68, 8-27, 2-68, 5-25, 4-34, 7-24, 9-84), [](0-31, 1-85, 4-55, 8-80, 5-58, 7-11, 6-69, 9-56, 3-73, 2-25), [](0-97, 5-98, 9-87, 8-47, 7-77, 4-90, 3-98, 2-80, 1-39, 6-40), [](1-97, 5-68, 0-44, 9-67, 2-44, 8-85, 3-78, 6-90, 7-33, 4-81), [](0-34, 3-76, 8-48, 7-61, 9-11, 2-36, 4-33, 6-98, 1-7, 5-44), [](0-44, 9-5, 4-85, 1-51, 5-58, 7-79, 2-95, 6-48, 3-86, 8-73), [](0-24, 1-63, 9-48, 7-77, 8-73, 6-74, 4-63, 5-17, 2-93, 3-84), [](0-51, 2-5, 4-40, 9-60, 1-46, 5-58, 8-54, 3-72, 6-29, 7-94))). It appears get_bench populates the structures with data from the jobshop entries, but I need help understanding how it is doing this. |
This paste has no annotations.