• Gurobi Staff

Could you please share a minimal reproducible example of your code describing the issue?

Please also post the exact error you get when trying to execute your code.

Hallo Jaromil,

Please find below the instantiation of part of the callback, that will be applied at the solution node. After I commented Ecurrent expression, then the optimization runs, without running the callback.

class subproblem1 : public GRBCallback {

public:

int *Pwind;
int* t_D_f;
GRBVar** Pbss;
GRBVar** Pbssd;

subproblem1(int *xPwind,int *xt_D_f,GRBVar**xPbss,GRBVar**xPbssd){

// numvars_sp1 = xnumvars;
Pwind = xPwind;
t_D_f = xt_D_f;
Pbss = xPbss;
Pbssd = xPbssd;
//Ecurrent = xEcurrent;
}

protected:

void callback() {

try {
if (where == GRB_CB_MIPSOL) {

// Query Zllower builds Zupper and compares its difference to epsilon tolerance

double zl = getDoubleInfo(GRB_CB_MIPSOL_OBJ);
int nodecnt = (int)getDoubleInfo(GRB_CB_MIPSOL_NODCNT);         // solution at node .
double obj = getDoubleInfo(GRB_CB_MIPSOL_OBJ);
int solcnt = getIntInfo(GRB_CB_MIPSOL_SOLCNT);
int Kb = 0;
int kf = 0;
Kb= T - 1;            //T is an extern const int variable

//do something with the Gurobi expression to get the same Gurobi variables to count.
while (! Kb == 0) {
for (int bess = 0; bess < N_BESS; bess++) {

p=Kb;

while (! p==Kb-6){

p -=1;

}

kf = p;

while (! kf==p+6){
kf +=1;
}

Kb - = 1;
}
}
}

}
}   catch (GRBException e) {
cout << "Error number: " << e.getErrorCode() << endl;
cout << e.getMessage() << endl;
}
catch (...) {
cout << "Error during callback" << endl;
}

}
};

• Gurobi Staff

What is the exact error you get when you run with your callback?

Hallo Jaromil,

I think we mismatch answers and questions please find above the piece of my callback.

• Gurobi Staff

These conditions

while (! Kb == 0) { ... while (! p==Kb-6){ ...while (! kf==p+6){

look strange. Did you mean

while ( Kb != 0) {... while (p != Kb-6){...while (kf != p+6){

or (equivalently)

while (! (Kb == 0)) {... while (! (p==Kb-6)){...while (! (kf==p+6)){

Your current code might be misunderstood as $$\texttt{(!Kb) == 0}$$.

• Gurobi Staff

Could you also point me to which arguments don't match according to the error you see?

• Gurobi Staff

The constructor

 subproblem1(int *xPwind,int *xt_D_f,GRBVar**xPbss,GRBVar**xPbssd)

is missing an argument for $$\texttt{Ecurrent}$$.

Hallo Jaromil,

Yeah ... because if I join it then I get the error message about the list of arguments.

"subproblem1 cb = subproblem1(P_wind,t_D_f,Pbss,Pbssd,Ecurrent);

Severity    Code    Line    Description    Project    File
Error (active)    E0289    1626    no instance of constructor "subproblem1::subproblem1" matches the argument list   "

• Gurobi Staff

Hi Alessandra,

The argument $$\texttt{GRBQuadExpr** Ecurrent}$$ is missing in the constructor $$\texttt{subproblem1}$$.

Does the following work?

class subproblem1 : public GRBCallback {public:    int *Pwind;    int* t_D_f;    GRBVar** Pbss;    GRBVar** Pbssd;    GRBQuadExpr** Ecurrent;    subproblem1(int *xPwind, int *xt_D_f,GRBVar **xPbss, GRBVar **xPbssd, GRBQuadExpr **xEcurrent){       // numvars_sp1 = xnumvars;        Pwind = xPwind;        t_D_f = xt_D_f;        Pbss = xPbss;        Pbssd = xPbssd;        Ecurrent = xEcurrent;    }protected:...

Best regards,
Jaromił