thats the problem mainly
Slackhighnumber = 9999
Slacklownumber = 0.000001
Stationnumber = size(Stationtask,1)
Tasknumbertotal = size(Taskmodel[1],2)
Tasknumber = Tasknumbertotal - 2
Ordernumber = size(Ordersubset,1)
Start = Tasknumbertotal
End = Tasknumbertotal - 1
MaxAGV = AVGnumber
Transporttime = 0
AGVEndtoStart = 0 #Time it takes the AGV to get from the last Station to the first Station
Oldordersnumber = size(Oldtaskstart,1)
m = nothing
m = Model(optimizer_with_attributes(Solver))
set_optimizer_attribute(m, "TimeLimit", Timelimitins)
#Variable
@variable(m, Endtime >= 0, Int);
@variable(m, Taskstart[1:Ordernumber, 1:Tasknumbertotal] >= 0, Int); #Divided everywhere by /100 as a Precisionlimit
@variable(m, Taskstartstation[1:Stationnumber, 1:Ordernumber, 1:Tasknumbertotal], Bin);
@variable(m, T1beforeT2[1:Ordernumber, 1:Tasknumbertotal, 1:Tasknumbertotal], Bin);
@variable(m, OT1beforeOT2[1:Ordernumber,1:Ordernumber, 1:Tasknumbertotal, 1:Tasknumbertotal], Bin);
@variable(m, OrderstartedbeforeOrder[1:Ordernumber,1:Ordernumber], Bin);
@variable(m, OrdernotfinshedbeforerOrder[1:Ordernumber,1:Ordernumber], Bin);
@variable(m, ActiveOrder[1:Ordernumber,1:Ordernumber], Bin);
@variable(m, Transport[1:Ordernumber,1:Tasknumbertotal,1:Tasknumbertotal], Bin);
#Fix
for Index in CartesianIndices(Oldtaskstart)
fix(Taskstart[Index[1], Index[2]], Oldtaskstart[Index[1], Index[2]]*100; force = true)
end
for Index in CartesianIndices(Oldtaskstartstation)
fix(Taskstartstation[Index[1], Index[2], Index[3]], Oldtaskstartstation[Index[1], Index[2], Index[3]]; force = true)
end
#complete all Orders ASAP
@objective(m, Min, Endtime + sum(Taskstart[O, End] for O = 1:Ordernumber)*Slacklownumber);
#Objective sub Constraint to find Maximum Endtime
@constraint(m, Endtime1[O=1:Ordernumber,T=1:Tasknumber], Endtime >= 0.01 * Taskstart[O, End]);
#Taskoverlapp + Transporttime
@constraint(m, Taskoverlap1[O=1:Ordernumber,T1=1:(Tasknumbertotal-1),T2=(T1+1):Tasknumbertotal], 0.01 * Taskstart[O,T1]+Taskmodel[Ordersubset[O]][T1]+Transport[O,T1,T2]*Transporttime<=0.01 * Taskstart[O,T2]+T1beforeT2[O,T1,T2]*Slackhighnumber);
@constraint(m, Taskoverlap2[O=1:Ordernumber,T1=1:(Tasknumbertotal-1),T2=(T1+1):Tasknumbertotal], 0.01 * Taskstart[O,T2]+Taskmodel[Ordersubset[O]][T2]+Transport[O,T1,T2]*Transporttime<=0.01 * Taskstart[O,T1]+(T1beforeT2[O,T1,T2]-1)*-Slackhighnumber);
@constraint(m, Transport1[S=1:Stationnumber,O=1:Ordernumber,T1=1:(Tasknumbertotal-1),T2=(T1+1):Tasknumbertotal],Taskstartstation[S,O,T1]-Taskstartstation[S,O,T2]<=Transport[O,T1,T2]);
#Constraint Start and End
@constraint(m, TaskstartStart[O=1:Ordernumber,T=1:Tasknumber], 0.01 * Taskstart[O, Start] <= 0.01 * Taskstart[O, T]);
@constraint(m, TaskstartEnd[O=1:Ordernumber,T=1:Tasknumber], 0.01 * Taskstart[O, T] + Taskmodel[Ordersubset[O]][T] <= 0.01 * Taskstart[O, End]);
#Constraint Precedence
@constraint(m, Precedencecon[O=1:Ordernumber,P=1:size(Precedence[Ordersubset[O]],1)], 0.01 * Taskstart[O, Precedence[Ordersubset[O]][P][1]] <= 0.01 * Taskstart[O, Precedence[Ordersubset[O]][P][2]]);
#Constraint every Starttask has 1 Station
@constraint(m, TaskStation1[O=1:Ordernumber,T=1:Tasknumbertotal],sum(Taskstartstation[S,O,T] for S=1:Stationnumber) == 1);
#Constraint Stationoverlap ////Start is not on the checked Station = (Taskstartstation[S,O1,T1]-1)*(-1)*Slackhighnumber+(Taskstartstation[S,O2,T2]-1)*(-1)*Slackhighnumber)
@constraint(m, Stationoverlap1[S=1:Stationnumber,O1=1:(Ordernumber-1), O2=(O1+1):Ordernumber,T1=1:Tasknumbertotal,T2=1:Tasknumbertotal],
0.01 * Taskstart[O1,T1]+Taskmodel[Ordersubset[O1]][T1]<=0.01 * Taskstart[O2,T2]+OT1beforeOT2[O1,O2,T1,T2]*Slackhighnumber + (Taskstartstation[S,O1,T1]-1)*-Slackhighnumber+(Taskstartstation[S,O2,T2]-1)*-Slackhighnumber);
@constraint(m, Stationoverlap2[S=1:Stationnumber,O1=1:(Ordernumber-1), O2=(O1+1):Ordernumber,T1=1:Tasknumbertotal,T2=1:Tasknumbertotal],
0.01 * Taskstart[O2,T2]+Taskmodel[Ordersubset[O2]][T2]<=0.01 * Taskstart[O1,T1]+(OT1beforeOT2[O1,O2,T1,T2]-1)*-Slackhighnumber + (Taskstartstation[S,O1,T1]-1)*-Slackhighnumber+(Taskstartstation[S,O2,T2]-1)*-Slackhighnumber);
#Constraint Starttask at corrosponding Station
@constraint(m, StationwithTask[S=1:Stationnumber, O=1:Ordernumber,T=1:Tasknumbertotal],Taskstartstation[S,O,T] <= Stationtask[S][T]);
#Constraint maximum avgs
@constraint(m, OrderstartedbeforeOrder1[O1=1:Ordernumber,O2 in 1:Ordernumber; O2!=O1],0.01 * Taskstart[O1,Start]-0.01 * Taskstart[O2,Start] + Slacklownumber <= OrderstartedbeforeOrder[O1,O2]*Slackhighnumber);
@constraint(m, OrdernotfinshedbeforerOrder1[O1=1:Ordernumber,O2=1:Ordernumber; O2!=O1],0.01 * Taskstart[O2,End]-0.01 * Taskstart[O1,Start] + AGVEndtoStart <= OrdernotfinshedbeforerOrder[O1,O2]*Slackhighnumber);
@constraint(m, ActiveOrder1[O1=1:Ordernumber,O2=1:Ordernumber; O2!=O1],ActiveOrder[O1,O2] >= OrdernotfinshedbeforerOrder[O1,O2] + OrderstartedbeforeOrder[O1,O2] - 1);
@constraint(m, MaxAVGs1[O1=1:Ordernumber],sum(ActiveOrder[O1,O2] for O2 in 1:Ordernumber if O2!=O1)<=MaxAGV-1);
#constraint path
@constraint(m, MovinginX[S1=1:(Stationnumber-1),S2=(S1+1):(Stationnumber),T=1:Tasknumber],Taskstartstation[S1,:,T] + Taskstartstation[S2,:,T+1].<= Stationpos[S2][1] - Stationpos[S1][1] +2);
#Constraint Taskstart after old Orders
@constraint(m, OldOrders[O=(Oldordersnumber+1):Ordernumber], 0.01 * Taskstart[O, Start] >= FinisholdOrders);
optimize!(m);
println("Termination status: ", JuMP.termination_status(m));
println("Primal status: ", JuMP.primal_status(m));
println("Objective value: ", JuMP.objective_value(m));
the binary variable are to determine if a process is for or after another process