43 assert(nodesel != NULL);
44 assert(strcmp(SCIPnodeselGetName(nodesel),
"ScipParaObjNodesel") == 0);
46 assert(selnode != NULL);
60 node = SCIPgetPrioChild(scip);
64 SCIPdebugMessage(
" -> selected prio child: lower=%g\n", SCIPnodeGetLowerbound(*selnode));
68 node = SCIPgetBestChild(scip);
72 SCIPdebugMessage(
" -> selected best child: lower=%g\n", SCIPnodeGetLowerbound(*selnode));
76 node = SCIPgetPrioSibling(scip);
80 SCIPdebugMessage(
" -> selected prio sibling: lower=%g\n", SCIPnodeGetLowerbound(*selnode));
84 node = SCIPgetBestSibling(scip);
88 SCIPdebugMessage(
" -> selected best sibling: lower=%g\n", SCIPnodeGetLowerbound(*selnode));
92 *selnode = SCIPgetBestNode(scip);
93 SCIPdebugMessage(
" -> selected best leaf: lower=%g\n",
94 *selnode != NULL ? SCIPnodeGetLowerbound(*selnode) : SCIPinfinity(scip));
108 SCIP_Real lowerbound1;
109 SCIP_Real lowerbound2;
111 assert(nodesel != NULL);
112 assert(strcmp(SCIPnodeselGetName(nodesel),
"ScipParaObjNodesel") == 0);
113 assert(scip != NULL);
115 lowerbound1 = SCIPnodeGetLowerbound(node1);
116 lowerbound2 = SCIPnodeGetLowerbound(node2);
117 if( SCIPisLT(scip, lowerbound1, lowerbound2) )
119 else if( SCIPisGT(scip, lowerbound1, lowerbound2) )
123 int nBranchVars1 = getNBoundChanges(node1);
124 int nBranchVars2 = getNBoundChanges(node2);
125 if( nBranchVars1 < nBranchVars2 )
127 else if( nBranchVars1 > nBranchVars2 )
135 estimate1 = SCIPnodeGetEstimate(node1);
136 estimate2 = SCIPnodeGetEstimate(node2);
137 if( (SCIPisInfinity(scip, estimate1) && SCIPisInfinity(scip, estimate2)) ||
138 (SCIPisInfinity(scip, -estimate1) && SCIPisInfinity(scip, -estimate2)) ||
139 SCIPisEQ(scip, estimate1, estimate2) )
141 SCIP_NODETYPE nodetype1;
142 SCIP_NODETYPE nodetype2;
144 nodetype1 = SCIPnodeGetType(node1);
145 nodetype2 = SCIPnodeGetType(node2);
146 if( nodetype1 == SCIP_NODETYPE_CHILD && nodetype2 != SCIP_NODETYPE_CHILD )
148 else if( nodetype1 != SCIP_NODETYPE_CHILD && nodetype2 == SCIP_NODETYPE_CHILD )
150 else if( nodetype1 == SCIP_NODETYPE_SIBLING && nodetype2 != SCIP_NODETYPE_SIBLING )
152 else if( nodetype1 != SCIP_NODETYPE_SIBLING && nodetype2 == SCIP_NODETYPE_SIBLING )
159 depth1 = SCIPnodeGetDepth(node1);
160 depth2 = SCIPnodeGetDepth(node2);
161 if( depth1 < depth2 )
163 else if( depth1 > depth2 )
169 if( SCIPisLT(scip, estimate1, estimate2) )
172 assert(SCIPisGT(scip, estimate1, estimate2));
179ScipParaObjNodesel::getNBoundChanges(
184 int depth = SCIPnodeGetDepth( node );
185 SCIP_VAR **branchVars =
new SCIP_VAR*[depth];
186 SCIP_Real *branchBounds =
new SCIP_Real[depth];
187 SCIP_BOUNDTYPE *boundTypes =
new SCIP_BOUNDTYPE[depth];
189 SCIPnodeGetAncestorBranchings( node, branchVars, branchBounds, boundTypes, &nBranchVars, depth );
190 if( nBranchVars > depth )
192 delete [] branchVars;
193 delete [] branchBounds;
194 delete [] boundTypes;
195 branchVars =
new SCIP_VAR*[nBranchVars];
196 branchBounds =
new SCIP_Real[nBranchVars];
197 boundTypes =
new SCIP_BOUNDTYPE[nBranchVars];
198 SCIPnodeGetAncestorBranchings( node, branchVars, branchBounds, boundTypes, &nBranchVars, nBranchVars );
205 int nVars = SCIPgetNVars(scip);
206 SCIP_VAR **vars = SCIPgetVars(scip);
207 int *iBranchVars =
new int[nBranchVars];
209 SCIP_HASHMAP* varmapLb;
210 SCIP_HASHMAP* varmapUb;
211 SCIP_CALL_ABORT( SCIPhashmapCreate(&varmapLb, SCIPblkmem(scip), nVars) );
212 SCIP_CALL_ABORT( SCIPhashmapCreate(&varmapUb, SCIPblkmem(scip), nVars) );
213 for(
int i = 0; i < nBranchVars; i++ )
216 if( boundTypes[i] == SCIP_BOUNDTYPE_LOWER )
218 if( !SCIPhashmapGetImage(varmapLb, branchVars[i]) )
220 SCIP_CALL_ABORT( SCIPhashmapInsert(varmapLb, branchVars[i], &iBranchVars[i] ) );
225 if( !SCIPhashmapGetImage(varmapUb, branchVars[i]) )
227 SCIP_CALL_ABORT( SCIPhashmapInsert(varmapUb, branchVars[i], &iBranchVars[i] ) );
231 SCIP_VAR **preBranchVars = branchVars;
232 SCIP_Real *preBranchBounds = branchBounds;
233 SCIP_BOUNDTYPE *preBboundTypes = boundTypes;
234 branchVars =
new SCIP_VAR*[nBranchVars+nVars*2];
235 branchBounds =
new SCIP_Real[nBranchVars+nVars*2];
236 boundTypes =
new SCIP_BOUNDTYPE[nBranchVars+nVars*2];
237 for(
int i = 0; i < nBranchVars; i++ )
239 branchVars[i] = preBranchVars[i];
240 branchBounds[i] = preBranchBounds[i];
241 boundTypes[i] = preBboundTypes[i];
243 int *iBranchVar = NULL;
244 for(
int i = 0; i < nVars; i++ )
246 iBranchVar = (
int *)SCIPhashmapGetImage(varmapLb, vars[i]);
252 branchBounds[*iBranchVar] = SCIPvarGetLbLocal(vars[i]);
258 if(
EPSGT( SCIPvarGetLbLocal(vars[i]), SCIPvarGetLbGlobal(vars[i]),
MINEPSILON ) )
260 branchVars[nBranchVars] = vars[i];
261 branchBounds[nBranchVars] = SCIPvarGetLbLocal(vars[i]);
262 boundTypes[nBranchVars] = SCIP_BOUNDTYPE_LOWER;
267 iBranchVar = (
int *)SCIPhashmapGetImage(varmapUb, vars[i]);
273 branchBounds[*iBranchVar] = SCIPvarGetUbLocal(vars[i]);
279 if(
EPSLT( SCIPvarGetUbLocal(vars[i]), SCIPvarGetUbGlobal(vars[i]),
MINEPSILON ) )
281 branchVars[nBranchVars] = vars[i];
282 branchBounds[nBranchVars] = SCIPvarGetUbLocal(vars[i]);
283 boundTypes[nBranchVars] = SCIP_BOUNDTYPE_UPPER;
289 SCIPhashmapFree(&varmapLb);
290 SCIPhashmapFree(&varmapUb);
291 delete [] preBranchVars;
292 delete [] preBranchBounds;
293 delete [] preBboundTypes;
294 delete [] iBranchVars;
298 delete [] branchVars;
299 delete [] branchBounds;
300 delete [] boundTypes;
ScipParaSolver * scipParaSolver
ParaParamSet * getParaParamSet()
get ParaParamSet object
bool isRacingStage()
check if Solver is in racing stage or not
bool getBoolParamValue(int param)
get bool parameter value
static const int NoAllBoundChangesTransferInRacing
static const int AllBoundChangesTransfer
#define DEFAULT_NUM_EPSILON
SCIP_DECL_NODESELSELECT(ScipParaObjNodesel::scip_select)
SCIP_DECL_NODESELCOMP(ScipParaObjNodesel::scip_comp)