最小化每个时间步

时间:2018-06-06 14:03:51

标签: cplex opl

我正在为峰值加载功能编写优化器。问题是我想在每个时间步骤中最小化我的功能。目前他只是在同一时间启动机器,并没有尝试改变这些起点。我的决策变量是机器的启动信号。为了更好地理解:

//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");

1 个答案:

答案 0 :(得分:0)

如果有人遇到同样的问题,我会解决。 我将LimitLoadPeak约束更改为以下内容:

// variables
 dvar int+ x[machines][time];
 dvar int+ MaxLoad;

// Optimization Problem last part ensures that when the machine is not running the idle power will be added
//minimize sum (i in time, j in machines, inew in ptime: (i-inew+1) in time) (x[j][i-inew+1]*power[j][inew] + Ipower[j]*(1-x[j][i-inew+1]));
minimize MaxLoad;
 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]))^2 <= MaxLoad;
    }

MaxLoad被定义为一个变量,总和的平方确保小的偏差也会影响结果。