-3

I'm a student new at CP optimizer. I want to make battery charging/discharging scheduling in CP.

So, I want to know how to charge or discharge at each sept.

using CP;


int numEVs = ...;
range EVs = 0..numEVs-1;
int time = ...;
range times = 0..time-1;


int cost[times] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
float min_soc[EVs] = [0.4,0.4,0.4,0.4,0.4];
float max_soc[EVs] = [0.9,0.9,0.9,0.9,0.9];
float Soc[EVs] = [0.4, 0.5, 0.6, 0.7, 0.8];
int k[times,EVs];
tuple EVs2 {
  key int id;
  int Cpower[times];
  int Dpower[times];
}


//float delSm[EVs] = Soc[EVs] - min_soc[EVs]; 
//float delSp[EVs] = Soc[EVs] - max_soc[EVs];
dvar interval t[i in times] optional size 1;
dvar int Pcmax[times, EVs]; // why I can't use float.
dvar int Pdmax[times, EVs];
//dvar int k[times,EVs] in 0..1;
dexpr float Cost = sum(t, j in EVs) (k[t,j]*cost[t]*Pcmax[t,j] - (1-k[t,j])*cost[t]*Pdmax[t,j]);

minimize Cost; // minimize charging/discharging price

subject to {
  forall(t, j in EVs)
  k[t,j]*Pcmax[t,j] - (1-k[t,j])*Pdmax[t,j] >= Soc[j]-min_soc[j] && k[t,j]*Pcmax[t,j] - (1-k[t,j])*Pdmax[t,j] <= Soc[j]-max_soc[j];  
// each EV's battery state of charge must less or bigger than limits. 
  forall(t, j in EVs)
    {
    Pdmax[t][j] >=0;
    Pdmax[t][j] <=10;
    Pcmax[t][j] >=0;
    Pcmax[t][j] <=8;
    }

this is my code, but not working help me plz.

sascha
  • 32,238
  • 6
  • 68
  • 110
JG.K
  • 1

1 Answers1

1

Copying a short version of the answer this question got at https://www.ibm.com/developerworks/community/forums/html/topic?id=5ffa03c4-68ed-44d4-b663-998592e22dec, where it was cross posted: The model is infeasible. You can use the conflict refiner to figure out which constraints render the problem infeasible and then fix them.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22