我正在为峰值负载功能编写优化器。问题是我想在每个时间步最小化我的功能。目前他只会在同一时间步启动机器,不会尝试改变这些起点。我的决策变量是机器的启动信号。为了更好地理解:
//parameters
int m1=...; //number of machines
int m2=...; //number of machines
int m3=...; //number of machines
int m4=...; //number of machines
int m=m1+m2+m3+m4; //total number of machines
int Parts1=...; //amount of parts from machines group 1
int Parts2=...; //amount of parts from machines group 2
int Parts3=...; //amount of parts from machines group 3
int Parts4=...; //amount of parts from machines group 4
int n=...; //number of time steps in overall simulation
int p=...; // number of time steps in power cycle
int k= n-p+2; //Declares the range to ensure that a machine can only start if it will finish in the shift
float MaxLoad=...;
range machines = 1..m; // range over all machines
range machines1 = 1..m1; //range over first machine group
range machines2 = (m1+1)..(m1+m2); //range over second machine group
range machines3 = (m1+m2+1)..(m1+m2+m3); //range over third machine group
range machines4 = (m1+m2+m3+1)..(m1+m2+m3+m4); //range over fourth machine group
range time = 1..n; //range over time steps
range ptime = 1..p; //range over powercycle steps
range sumbackStart = p..n; //machine summation backwards (i-p+1) ensures that sum starts at 1 and not at -p !!
range sumbackFinish = k..n; //no starts to the end of the shift if the machine will not finish the working piece
float power [machines][ptime]=...;
// variables
dvar int+ x[machines][time];
// Optimization Problem
minimize sum (i in time) (sum(j in machines, inew in ptime: (i-inew+1) in time) x[j][i-inew+1]*power[j][inew]);
subject to {
Range_binaryVariable: //Ensures that the decision variable is only 1 or 0
forall (j in machines, i in time){
0 <= x[j][i] <= 1;
}
/*LimitLoadPeak: //Limits the maximum Peak
forall (i in time){
sum (j in machines, inew in ptime: (i-inew+1) in time) x[j][i-inew+1]*power[j][inew] <= 100;
}*/
PartStart: //Ensures that the machine only starts
forall (j in machines, i in sumbackStart){
sum (inewnew in (i-p+1)..i) x[j][inewnew] <= 1;
}
PartFinisher: //Ensures that the machines only start if they will finish during the given time steps or shift
forall (j in machines){
sum (inewnewnew in sumbackFinish) x[j][inewnewnew] <= 0;
}
//Ensures that the work pieces, which need to be produced by the machine groups, will be produced
PartminM1:
Parts1 <= sum (j in machines1, i in time) x[j][i];
PartminM2:
Parts2 <= sum (j in machines2, i in time) x[j][i];
PartminM3:
Parts3 <= sum (j in machines3, i in time) x[j][i];
PartminM4:
Parts4 <= sum (j in machines4, i in time) x[j][i];
}
我已经实现了峰值限制,但我的函数实际上应该自己完成并尝试改变工作流程。
我希望你能理解我的问题,我会非常感谢你的帮助。
SheetConnection my_sheet ("OptiV7_Daten.xlsx");
n from SheetRead(my_sheet,"'Information'!timesteps");
p from SheetRead(my_sheet,"'Information'!powercycle");
MaxLoad from SheetRead(my_sheet,"'Machine_Data_timesized'!MaxLoad");
Parts1 from SheetRead(my_sheet,"'Information'!Parts1");
Parts2 from SheetRead(my_sheet,"'Information'!Parts2");
Parts3 from SheetRead(my_sheet,"'Information'!Parts3");
Parts4 from SheetRead(my_sheet,"'Information'!Parts4");
m1 from SheetRead(my_sheet,"'Information'!machines1");
m2 from SheetRead(my_sheet,"'Information'!machines2");
m3 from SheetRead(my_sheet,"'Information'!machines3");
m4 from SheetRead(my_sheet,"'Information'!machines4");
power from SheetRead(my_sheet,"'Machine_Data_timesized'!Power");