% Number of tasks
int: numTasks = 5;
% Number of days available for scheduling
int: numDays = 10;
% Duration of each task (in days)
array[1..numTasks] of int: duration = [2, 3, 1, 4, 2];
% Dependencies between tasks (task 2 depends on task 1, etc.)
array[1..numTasks, 1..numTasks] of bool: dependency = array2d(1..numTasks, 1..numTasks,
[ 0, 1, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0 ]);
% Decision variables: start day for each task
array[1..numTasks] of var 1..numDays: startDay;
% Constraint: task must finish within the schedule
constraint forall(i in 1..numTasks) (
startDay[i] + duration[i] - 1 <= numDays
);
% Constraint: dependencies between tasks
constraint forall(i in 1..numTasks, j in 1..numTasks) (
if dependency[i,j] then
startDay[j] >= startDay[i] + duration[i]
else
true
endif
);
% Optimization goal: minimize the last finishing day
var int: lastFinish = max(i in 1..numTasks) (startDay[i] + duration[i] - 1);
solve minimize lastFinish;
% Output
output ["Task " ++ show(i) ++ " starts on day " ++ show(startDay[i]) | i in 1..numTasks];
Running TonySched.mzn | 81msec |
TonySched:12-55.17-22: MiniZinc: type error: cannot determine coercion from type array[int,int] of int to type array[int,int] of bool Process finished with non-zero exit code 1. Finished in 81msec. |
I'm not sure yet.ShitGPT?
It's too early to tell David. I have had some clear, quick responses to some questions/subjects, but much less than stellar in others. I asked chatGPT some questions about furnace symptoms and also about car tires/noises and got direct, useful responses. However, I have had some confusing, circuitous responses when dealing with Access/vba/vbe. My experience says that the software (Ver 3.5 that I have used) often makes things up (hallucinations). Several times, different sessions, I get a code snippet response from chatGPT that include s properties that don't exist. I also tried Bing chat with a question I had posed to chatGPT-- similar responses and seemed to be going in a circle. Bing chat seems just another interface to chatGPT, but I haven't pursued it enough to comment one way or the other.ShitGPT?
%Dec -11-23 ----this is my working testing version % WORKING
%output code to show teams vs True/False from Jip Dekker
% THE PROBLEM/PUZZLE TO BE SOLVED/SATISFIED
% Teams are made up of 2 player unique combinations from 8 choose 2. (A,B,C,D,E,F,G,H)
% A team can only participate in 1 activity in 1 session, then Is removed from further play.
% A Player, regardless of Team, can only play 1 activity 0 or 1 time.
% A Player can only play in 1 activity per session.
% Each Activity in each Session has exactly 1 Team assigned to it.
% The Activities are CHECKERS, HORSESHOES, DARTS, TABLE_TENNIS
% The Sessions are 9 AM, 10 AM, 11 Am, 12 Noon.
%----------miniZinc instructions/code follows--------------
include "globals.mzn"; %include minizinc globals library
%set up main factors of the puzzle
enum ACTIVITY = {CHECKERS, HORSESHOES, DARTS, TABLE_TENNIS}; %4 activities
enum PLAYER = {A, B, C, D, E, F, G, H}; %8 Players
enum SESSION = Session(9..12); %4 Sessions
% Define the set of pairs of players for teams 8 choose 2
array [int] of set of PLAYER: TEAMS = [{A, B}, {A, C}, {A, D}, {A, E}, {A, F}, {A, G},
{A, H}, {B, C}, {B, D}, {B, E}, {B, F}, {B, G}, {B, H}, {C, D}, {C, E}, {C, F}, {C, G},
{C, H}, {D, E}, {D, F}, {D, G}, {D, H}, {E, F}, {E, G}, {E, H}, {F, G}, {F, H}, {G, H}];
% Define the decision variable for the assignment of teams to activities in sessions
array[index_set(TEAMS), ACTIVITY, SESSION] of var bool: x;
% 3 dimensional array of booleans
% Each element of the array x is a boolean variable that can be either true or false.
% The value of x[t,a,s] indicates whether team t performs activity a in session s or not.
% Define the constraints of the problem
% A team can only play one activity one time in one session and then that combination/team is excluded from further play
constraint forall(t in index_set(TEAMS), a in ACTIVITY) (
sum(s in SESSION) (x[t, a, s]) <= 1 );
constraint forall(t in index_set(TEAMS),s in SESSION ) (
sum(a in ACTIVITY) (x[t, a, s]) <= 1);
constraint forall(t in index_set(TEAMS) ) (
sum(a in ACTIVITY,s in SESSION) (x[t, a, s]) <= 1);
% A player can only participate once in a specific activity, regardless of the team and the session
constraint forall(p in PLAYER, a in ACTIVITY) (
sum(t in index_set(TEAMS) where p in TEAMS[t], s in SESSION) (x[t, a, s]) <= 1);
% A player can only participate once in a session, regardless of the team and the activity
constraint forall(p in PLAYER,s in SESSION ) (
sum(t in index_set(TEAMS) where p in TEAMS[t],a in ACTIVITY ) (x[t, a, s]) <= 1);
% Each activity in each session has exactly one team assigned to it
constraint forall(a in ACTIVITY, s in SESSION) (
sum(t in index_set(TEAMS)) (x[t, a, s]) == 1);
solve satisfy;
% JED I switched Session and Actvity in line below to get Activity columns, Session rows
% Got assistance from Jip Dekker to convert 3D array of booleans to 2D array showing Teams
% Define a 2D array y showing session and activity with values of players making up Teams
array[SESSION,ACTIVITY] of set of PLAYER: y ::output_only = [
(s,a): {p | i in index_set(TEAMS) where fix(x[i,a,s]), p in TEAMS[i]}
| s in SESSION, a in ACTIVITY];
%Output the 2D array showing session and activity with values of players making up Teams
output [show2d(y) ++ "\n"];
[\code]
----------------------------a few solutions ------------------------------
[| CHECKERS: HORSESHOES: DARTS: TABLE_TENNIS:
| Session(9): {B, F}, {A, H}, {D, E}, {C, G}
| Session(10): {A, G}, {B, E}, {C, H}, {D, F}
| Session(11): {C, E}, {D, G}, {A, F}, {B, H}
| Session(12): {D, H}, {C, F}, {B, G}, {A, E}
|]
----------
[| CHECKERS: HORSESHOES: DARTS: TABLE_TENNIS:
| Session(9): {D, F}, {A, H}, {C, E}, {B, G}
| Session(10): {A, G}, {D, E}, {B, H}, {C, F}
| Session(11): {B, E}, {C, G}, {A, F}, {D, H}
| Session(12): {C, H}, {B, F}, {D, G}, {A, E}
|]
----------
[| CHECKERS: HORSESHOES: DARTS: TABLE_TENNIS:
| Session(9): {C, F}, {A, H}, {D, E}, {B, G}
| Session(10): {A, G}, {C, E}, {B, H}, {D, F}
| Session(11): {B, E}, {D, G}, {A, F}, {C, H}
| Session(12): {D, H}, {B, F}, {C, G}, {A, E}
|]
----------
[| CHECKERS: HORSESHOES: DARTS: TABLE_TENNIS:
| Session(9): {B, E}, {A, H}, {D, G}, {C, F}
| Session(10): {A, G}, {B, F}, {C, E}, {D, H}
| Session(11): {C, H}, {D, E}, {A, F}, {B, G}
| Session(12): {D, F}, {C, G}, {B, H}, {A, E}
|]
----------
[| CHECKERS: HORSESHOES: DARTS: TABLE_TENNIS:
| Session(9): {B, E}, {A, H}, {C, G}, {D, F}
| Session(10): {A, G}, {B, F}, {D, E}, {C, H}
| Session(11): {D, H}, {C, E}, {A, F}, {B, G}
| Session(12): {C, F}, {D, G}, {B, H}, {A, E}
|]
----------