/** creates a new node entry in the VBC output file */ SCIP_RETCODE SCIPvbcNewChild( SCIP_VBC* vbc, /**< VBC information */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node /**< new node, that was created */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; size_t parentnodenum; size_t nodenum; assert(vbc != NULL); assert(stat != NULL); assert(node != NULL); /* check, if VBC output should be created */ if( vbc->file == NULL ) return SCIP_OKAY; /* vbc is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return SCIP_OKAY; /* insert mapping node -> nodenum into hash map */ if( stat->ncreatednodesrun >= (SCIP_Longint)INT_MAX ) { SCIPerrorMessage("too many nodes to store in the VBC file\n"); return SCIP_INVALIDDATA; } nodenum = (size_t)stat->ncreatednodesrun; assert(nodenum > 0); SCIP_CALL( SCIPhashmapInsert(vbc->nodenum, node, (void*)nodenum) ); /* get nodenum of parent node from hash map */ parentnodenum = (node->parent != NULL ? (size_t)SCIPhashmapGetImage(vbc->nodenum, node->parent) : 0); assert(node->parent == NULL || parentnodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); printTime(vbc, stat); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "N %d %d %d\n", (int)parentnodenum, (int)nodenum, SCIP_VBCCOLOR_UNSOLVED); printTime(vbc, stat); if( branchvar != NULL ) { SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, SCIPnodeGetLowerbound(node)); } else { SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPnodeGetLowerbound(node)); } return SCIP_OKAY; }
/** marks node as solved in visualization output file */ void SCIPvisualSolvedNode( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node /**< node, that was solved */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; SCIP_Real lowerbound; size_t nodenum; assert( visual != NULL ); assert( stat != NULL ); assert( node != NULL ); /* check whether output should be created */ if ( visual->vbcfile == NULL && visual->bakfile == NULL ) return; /* visualization is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return; /* get node num from hash map */ nodenum = (size_t)SCIPhashmapGetImage(visual->nodenum, node); assert(nodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); /* determine lower bound */ if ( set->visual_objextern ) lowerbound = SCIPretransformObj(set->scip, SCIPnodeGetLowerbound(node)); else lowerbound = SCIPnodeGetLowerbound(node); if ( visual->vbcfile != NULL ) { printTime(visual, stat, TRUE); if( branchvar != NULL ) { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\\nnr:\\t%" SCIP_LONGINT_FORMAT "\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, lowerbound, stat->nnodes); } else { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\\nnr:\\t%" SCIP_LONGINT_FORMAT "\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), lowerbound, stat->nnodes); } vbcSetColor(visual, stat, node, SCIP_VBCCOLOR_SOLVED); } /* do nothing for BAK */ }
/** changes the color of the node to the color of solved nodes */ void SCIPvbcSolvedNode( SCIP_VBC* vbc, /**< VBC information */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node /**< node, that was solved */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; size_t nodenum; assert(vbc != NULL); assert(stat != NULL); assert(node != NULL); /* check, if VBC output should be created */ if( vbc->file == NULL ) return; /* vbc is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return; /* get node num from hash map */ nodenum = (size_t)SCIPhashmapGetImage(vbc->nodenum, node); assert(nodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); printTime(vbc, stat); if( branchvar != NULL ) { SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\\nnr:\\t%"SCIP_LONGINT_FORMAT"\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, SCIPnodeGetLowerbound(node), stat->nnodes); } else { SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\\nnr:\\t%"SCIP_LONGINT_FORMAT"\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPnodeGetLowerbound(node), stat->nnodes); } vbcSetColor(vbc, stat, node, SCIP_VBCCOLOR_SOLVED); }
/** displays a time value fitting in a given width */ void SCIPdispTime( SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ FILE* file, /**< output stream */ SCIP_Real val, /**< value in seconds to display */ int width /**< width to fit into */ ) { assert(width >= 1); if( width == 1 ) { if( val < 0.0 ) SCIPmessageFPrintInfo(messagehdlr, file, "-"); else if( val < 10.0 ) SCIPmessageFPrintInfo(messagehdlr, file, "%.0f", val); else SCIPmessageFPrintInfo(messagehdlr, file, "+"); } else { char format[SCIP_MAXSTRLEN]; SCIP_Longint maxval; int timepower; int i; maxval = 1; for( i = 0; i < width-1; ++i ) maxval *= 10; if( val < 0.0 ) maxval /= 10; timepower = 0; while( REALABS(val) + 0.5 >= maxval && timepower < MAXTIMEPOWER ) { timepower++; val /= timepowerval[timepower]; } if( REALABS(val) + 0.05 < maxval/100 ) /*lint !e653*/ (void) SCIPsnprintf(format, SCIP_MAXSTRLEN, "%%%d.1f%c", width-1, timepowerchar[timepower]); else (void) SCIPsnprintf(format, SCIP_MAXSTRLEN, "%%%d.0f%c", width-1, timepowerchar[timepower]); if( width == 2 && val < 0.0 ) SCIPmessageFPrintInfo(messagehdlr, file, "-%c", timepowerchar[timepower]); else SCIPmessageFPrintInfo(messagehdlr, file, (const char*)format, val); } }
/** prints current solution time to visualization output file */ static void printTime( SCIP_VISUAL* visual, /**< visualization information */ SCIP_STAT* stat, /**< problem statistics */ SCIP_Bool vbc /**< whether we use vbc output (bak otherwise) */ ) { SCIP_Longint step; int hours; int mins; int secs; int hunds; assert( visual != NULL ); assert( stat != NULL ); if( visual->userealtime ) { double time; time = SCIPclockGetTime(stat->solvingtime); step = (SCIP_Longint)(time * 100.0); } else { step = visual->timestep; visual->timestep++; } if ( vbc ) { hours = (int)(step / (60*60*100)); step %= 60*60*100; mins = (int)(step / (60*100)); step %= 60*100; secs = (int)(step / 100); step %= 100; hunds = (int)step; SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "%02d:%02d:%02d.%02d ", hours, mins, secs, hunds); } else { SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "%f ", (SCIP_Real) step/100.0); } }
/** displays a long integer in decimal form fitting in a given width */ void SCIPdispLongint( SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ FILE* file, /**< output stream */ SCIP_Longint val, /**< value to display */ int width /**< width to fit into */ ) { assert(width >= 1); if( width == 1 ) { if( val < 0 ) SCIPmessageFPrintInfo(messagehdlr, file, "-"); else if( val < 10 ) SCIPmessageFPrintInfo(messagehdlr, file, "%"SCIP_LONGINT_FORMAT, val); else SCIPmessageFPrintInfo(messagehdlr, file, "+"); } else { char format[SCIP_MAXSTRLEN]; SCIP_Longint maxval; int decpower; int i; maxval = 1; for( i = 0; i < width-1; ++i ) maxval *= 10; if( val < 0 ) maxval /= 10; decpower = 0; while( ABS(val) >= maxval && decpower < MAXDECPOWER ) { decpower++; val /= 1000; } (void) SCIPsnprintf(format, SCIP_MAXSTRLEN, "%%%d"SCIP_LONGINT_FORMAT"%c", width-1, decpowerchar[decpower]); if( width == 2 && val < 0 ) SCIPmessageFPrintInfo(messagehdlr, file, "-%c", decpowerchar[decpower]); else SCIPmessageFPrintInfo(messagehdlr, file, (const char*)format, val); } }
/** initializes VBC information and creates a file for VBC output */ SCIP_RETCODE SCIPvbcInit( SCIP_VBC* vbc, /**< VBC information */ BMS_BLKMEM* blkmem, /**< block memory */ SCIP_SET* set, /**< global SCIP settings */ SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ ) { assert(vbc != NULL); assert(set != NULL); assert(set->vbc_filename != NULL); if( set->vbc_filename[0] == '-' && set->vbc_filename[1] == '\0' ) return SCIP_OKAY; SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_NORMAL, "storing VBC information in file <%s>\n", set->vbc_filename); vbc->file = fopen(set->vbc_filename, "w"); vbc->timestep = 0; vbc->lastnode = NULL; vbc->lastcolor = SCIP_VBCCOLOR_NONE; vbc->userealtime = set->vbc_realtime; if( vbc->file == NULL ) { SCIPerrorMessage("error creating file <%s>\n", set->vbc_filename); SCIPprintSysError(set->vbc_filename); return SCIP_FILECREATEERROR; } SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "#TYPE: COMPLETE TREE\n"); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "#TIME: SET\n"); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "#BOUNDS: SET\n"); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "#INFORMATION: STANDARD\n"); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "#NODE_NUMBER: NONE\n"); SCIP_CALL( SCIPhashmapCreate(&vbc->nodenum, blkmem, SCIP_HASHSIZE_VBC) ); return SCIP_OKAY; }
/** outputs a new global upper bound to the VBC output file */ void SCIPvbcUpperbound( SCIP_VBC* vbc, /**< VBC information */ SCIP_STAT* stat, /**< problem statistics */ SCIP_Real upperbound /**< new upper bound */ ) { assert(vbc != NULL); /* check, if VBC output should be created */ if( vbc->file == NULL ) return; printTime(vbc, stat); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "U %f\n", upperbound); }
/** outputs a new global upper bound to the visualization output file */ void SCIPvisualUpperbound( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_Real upperbound /**< new upper bound */ ) { assert( visual != NULL ); /* check, if VBC output should be created */ if( visual->vbcfile == NULL ) return; /* determine external upper bound */ if ( set->visual_objextern ) upperbound = SCIPretransformObj(set->scip, upperbound); printTime(visual, stat, TRUE); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "U %f\n", upperbound); /* do nothing for BAK */ }
/** changes the color of the node to the given color */ static void vbcSetColor( SCIP_VBC* vbc, /**< VBC information */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node, /**< node to change color for */ SCIP_VBCCOLOR color /**< new color of node, or SCIP_VBCCOLOR_NONE */ ) { assert(vbc != NULL); assert(node != NULL); if( vbc->file != NULL && color != SCIP_VBCCOLOR_NONE && (node != vbc->lastnode || color != vbc->lastcolor) ) { size_t nodenum; nodenum = (size_t)SCIPhashmapGetImage(vbc->nodenum, node); assert(nodenum > 0); printTime(vbc, stat); SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "P %d %d\n", (int)nodenum, color); vbc->lastnode = node; vbc->lastcolor = color; } }
/** prints out GCG version */ static void GCGprintVersion( SCIP* scip, /**< SCIP data structure */ FILE* file /**< output file (or NULL for standard output) */ ) { assert(scip != NULL); SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "GCG version %d.%d.%d", GCGmajorVersion(), GCGminorVersion(), GCGtechVersion()); #if GCG_SUBVERSION > 0 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, ".%d", GCGsubversion()); #endif SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, " [GitHash: %s]", GCGgetGitHash()); SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "\n"); SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, "Copyright (c) 2010-2013 Operations Research, RWTH Aachen University\n"); SCIPmessageFPrintInfo(SCIPgetMessagehdlr(scip), file, " Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)\n\n"); }
/** prints current solution time to VBC output file */ static void printTime( SCIP_VBC* vbc, /**< VBC information */ SCIP_STAT* stat /**< problem statistics */ ) { SCIP_Longint step; int hours; int mins; int secs; int hunds; assert(vbc != NULL); assert(stat != NULL); if( vbc->userealtime ) { double time; time = SCIPclockGetTime(stat->solvingtime); step = (SCIP_Longint)(time * 100.0); } else { step = vbc->timestep; vbc->timestep++; } hours = (int)(step / (60*60*100)); step %= 60*60*100; mins = (int)(step / (60*100)); step %= 60*100; secs = (int)(step / 100); step %= 100; hunds = (int)step; SCIPmessageFPrintInfo(vbc->messagehdlr, vbc->file, "%02d:%02d:%02d.%02d ", hours, mins, secs, hunds); }
/** prints error message for return code via message handler */ void SCIPretcodePrint( SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ FILE* file, /**< file stream to write error message */ SCIP_RETCODE retcode /**< SCIP return code causing the error */ ) { switch( retcode ) { case SCIP_OKAY: SCIPmessageFPrintInfo(messagehdlr, file, "normal termination"); break; case SCIP_ERROR: SCIPmessageFPrintInfo(messagehdlr, file, "unspecified error"); break; case SCIP_NOMEMORY: SCIPmessageFPrintInfo(messagehdlr, file, "insufficient memory error"); break; case SCIP_READERROR: SCIPmessageFPrintInfo(messagehdlr, file, "read error"); break; case SCIP_WRITEERROR: SCIPmessageFPrintInfo(messagehdlr, file, "write error"); break; case SCIP_NOFILE: SCIPmessageFPrintInfo(messagehdlr, file, "file not found error"); break; case SCIP_FILECREATEERROR: SCIPmessageFPrintInfo(messagehdlr, file, "cannot create file"); break; case SCIP_LPERROR: SCIPmessageFPrintInfo(messagehdlr, file, "error in LP solver"); break; case SCIP_NOPROBLEM: SCIPmessageFPrintInfo(messagehdlr, file, "no problem exists"); break; case SCIP_INVALIDCALL: SCIPmessageFPrintInfo(messagehdlr, file, "method cannot be called at this time in solution process"); break; case SCIP_INVALIDDATA: SCIPmessageFPrintInfo(messagehdlr, file, "method cannot be called with this type of data"); break; case SCIP_INVALIDRESULT: SCIPmessageFPrintInfo(messagehdlr, file, "method returned an invalid result code"); break; case SCIP_PLUGINNOTFOUND: SCIPmessageFPrintInfo(messagehdlr, file, "a required plugin was not found"); break; case SCIP_PARAMETERUNKNOWN: SCIPmessageFPrintInfo(messagehdlr, file, "the parameter with the given name was not found"); break; case SCIP_PARAMETERWRONGTYPE: SCIPmessageFPrintInfo(messagehdlr, file, "the parameter is not of the expected type"); break; case SCIP_PARAMETERWRONGVAL: SCIPmessageFPrintInfo(messagehdlr, file, "the value is invalid for the given parameter"); break; case SCIP_KEYALREADYEXISTING: SCIPmessageFPrintInfo(messagehdlr, file, "the given key is already existing in table"); break; case SCIP_MAXDEPTHLEVEL: SCIPmessageFPrintInfo(messagehdlr, file, "maximal branching depth level exceeded"); break; default: SCIPmessageFPrintInfo(messagehdlr, file, "unknown error code"); break; } }
/** initializes visualization information and creates a file for visualization output */ SCIP_RETCODE SCIPvisualInit( SCIP_VISUAL* visual, /**< visualization information */ BMS_BLKMEM* blkmem, /**< block memory */ SCIP_SET* set, /**< global SCIP settings */ SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ ) { assert( visual != NULL ); assert( set != NULL ); assert( set->visual_vbcfilename != NULL ); assert( set->visual_bakfilename != NULL ); assert( visual->nodenum == NULL ); /* check whether we should initialize VBC output */ if ( set->visual_vbcfilename[0] != '-' || set->visual_vbcfilename[1] != '\0' ) { SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_NORMAL, "storing VBC information in file <%s>\n", set->visual_vbcfilename); visual->vbcfile = fopen(set->visual_vbcfilename, "w"); visual->timestep = 0; visual->lastnode = NULL; visual->lastcolor = SCIP_VBCCOLOR_NONE; visual->userealtime = set->visual_realtime; if( visual->vbcfile == NULL ) { SCIPerrorMessage("error creating file <%s>\n", set->visual_vbcfilename); SCIPprintSysError(set->visual_vbcfilename); return SCIP_FILECREATEERROR; } SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "#TYPE: COMPLETE TREE\n"); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "#TIME: SET\n"); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "#BOUNDS: SET\n"); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "#INFORMATION: STANDARD\n"); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "#NODE_NUMBER: NONE\n"); } /* check whether we should initialize BAK output */ if ( set->visual_bakfilename[0] != '-' || set->visual_bakfilename[1] != '\0' ) { SCIPmessagePrintVerbInfo(messagehdlr, set->disp_verblevel, SCIP_VERBLEVEL_NORMAL, "storing BAK information in file <%s>\n", set->visual_bakfilename); visual->bakfile = fopen(set->visual_bakfilename, "w"); visual->timestep = 0; visual->lastnode = NULL; visual->lastcolor = SCIP_VBCCOLOR_NONE; visual->userealtime = set->visual_realtime; if ( visual->bakfile == NULL ) { SCIPerrorMessage("error creating file <%s>\n", set->visual_bakfilename); SCIPprintSysError(set->visual_bakfilename); return SCIP_FILECREATEERROR; } } /* possibly init hashmap for nodes */ if ( visual->vbcfile != NULL || visual->bakfile != NULL ) { SCIP_CALL( SCIPhashmapCreate(&visual->nodenum, blkmem, SCIP_HASHSIZE_VBC) ); } return SCIP_OKAY; }
/** prints one line of output with the active display columns */ SCIP_RETCODE SCIPdispPrintLine( SCIP_SET* set, /**< global SCIP settings */ SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ SCIP_STAT* stat, /**< problem statistics data */ FILE* file, /**< output file (or NULL for standard output) */ SCIP_Bool forcedisplay /**< should the line be printed without regarding frequency? */ ) { assert(set != NULL); assert(set->disp_freq >= -1); assert(set->disp_headerfreq >= -1); assert(stat != NULL); if( (SCIP_VERBLEVEL)set->disp_verblevel < SCIP_VERBLEVEL_NORMAL || set->disp_freq == -1 ) return SCIP_OKAY; if( forcedisplay || (stat->nnodes != stat->lastdispnode && set->disp_freq > 0 && (stat->nnodes % set->disp_freq == 0 || stat->nnodes == 1)) ) { int i; int j; SCIP_Bool stripline; /* display header line */ if( (set->disp_headerfreq == 0 && stat->ndisplines == 0) || (set->disp_headerfreq > 0 && stat->ndisplines % set->disp_headerfreq == 0) ) { int fillspace; stripline = FALSE; for( i = 0; i < set->ndisps; ++i ) { assert(set->disps[i] != NULL); if( set->disps[i]->active ) { if( stripline ) SCIPmessageFPrintInfo(messagehdlr, file, "|"); fillspace = set->disps[i]->width - (int)strlen(set->disps[i]->header); for( j = 0; j < (fillspace)/2; ++j ) SCIPmessageFPrintInfo(messagehdlr, file, " "); SCIPmessageFPrintInfo(messagehdlr, file, "%s", (const char*)set->disps[i]->header); for( j = 0; j < (fillspace+1)/2; ++j ) SCIPmessageFPrintInfo(messagehdlr, file, " "); stripline = set->disps[i]->stripline; } } SCIPmessageFPrintInfo(messagehdlr, file, "\n"); } /* display node information line */ stripline = FALSE; for( i = 0; i < set->ndisps; ++i ) { assert(set->disps[i] != NULL); if( set->disps[i]->active ) { if( stripline ) SCIPmessageFPrintInfo(messagehdlr, file, "|"); SCIP_CALL( SCIPdispOutput(set->disps[i], set, file) ); stripline = set->disps[i]->stripline; } } SCIPmessageFPrintInfo(messagehdlr, file, "\n"); fflush(stdout); stat->lastdispnode = stat->nnodes; stat->ndisplines++; } return SCIP_OKAY; }
/** creates a new node entry in the visualization output file */ SCIP_RETCODE SCIPvisualNewChild( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node /**< new node, that was created */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; SCIP_Real lowerbound; size_t parentnodenum; size_t nodenum; assert( visual != NULL ); assert( stat != NULL ); assert( node != NULL ); /* visualization is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return SCIP_OKAY; /* check whether output should be created */ if ( visual->vbcfile == NULL && visual->bakfile == NULL ) return SCIP_OKAY; /* insert mapping node -> nodenum into hash map */ if( stat->ncreatednodesrun >= (SCIP_Longint)INT_MAX ) { SCIPerrorMessage("too many nodes to store in the visualization file\n"); return SCIP_INVALIDDATA; } nodenum = (size_t)stat->ncreatednodesrun; assert(nodenum > 0); SCIP_CALL( SCIPhashmapInsert(visual->nodenum, node, (void*)nodenum) ); /* get nodenum of parent node from hash map */ parentnodenum = (node->parent != NULL ? (size_t)SCIPhashmapGetImage(visual->nodenum, node->parent) : 0); assert(node->parent == NULL || parentnodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); /* determine lower bound */ if ( set->visual_objextern ) lowerbound = SCIPretransformObj(set->scip, SCIPnodeGetLowerbound(node)); else lowerbound = SCIPnodeGetLowerbound(node); if ( visual->vbcfile != NULL ) { printTime(visual, stat, TRUE); SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "N %d %d %d\n", (int)parentnodenum, (int)nodenum, SCIP_VBCCOLOR_UNSOLVED); printTime(visual, stat, TRUE); if( branchvar != NULL ) { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, lowerbound); } else { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), lowerbound); } } /* For BAK, not all available information is available here. Use SCIPvisualUpdateChild() instead */ return SCIP_OKAY; }
/** updates a node entry in the visualization output file */ SCIP_RETCODE SCIPvisualUpdateChild( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node /**< new node, that was created */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; SCIP_Real lowerbound; size_t nodenum; assert( visual != NULL ); assert( stat != NULL ); assert( node != NULL ); /* check whether output should be created */ if ( visual->vbcfile == NULL && visual->bakfile == NULL ) return SCIP_OKAY; /* visualization is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return SCIP_OKAY; /* get node num from hash map */ nodenum = (size_t)SCIPhashmapGetImage(visual->nodenum, node); assert(nodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); /* determine lower bound */ if ( set->visual_objextern ) lowerbound = SCIPretransformObj(set->scip, SCIPnodeGetLowerbound(node)); else lowerbound = SCIPnodeGetLowerbound(node); if ( visual->vbcfile != NULL ) { printTime(visual, stat, TRUE); if( branchvar != NULL ) { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, lowerbound); } else { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), lowerbound); } } if ( visual->bakfile != NULL ) { size_t parentnodenum; SCIP_Real* lpcandsfrac; SCIP_Real sum = 0.0; int nlpcands = 0; char t = 'M'; const char* nodeinfo; int j; /* determine branching type */ if ( branchvar != NULL ) t = (branchtype == SCIP_BOUNDTYPE_LOWER ? 'R' : 'L'); /* get nodenum of parent node from hash map */ parentnodenum = (node->parent != NULL ? (size_t)SCIPhashmapGetImage(visual->nodenum, node->parent) : 0); assert(node->parent == NULL || parentnodenum > 0); /* update info depending on the node type */ switch( SCIPnodeGetType(node) ) { case SCIP_NODETYPE_CHILD: /* the child is a new candidate */ nodeinfo = "candidate"; break; case SCIP_NODETYPE_FOCUSNODE: /* the focus node is updated to a branch node */ nodeinfo = "branched"; /* calculate infeasibility information */ SCIP_CALL( SCIPgetLPBranchCands(set->scip, NULL, NULL, &lpcandsfrac, &nlpcands, NULL, NULL) ); for (j = 0; j < nlpcands; ++j) sum += lpcandsfrac[j]; break; default: SCIPerrorMessage("Error: Unexpected node type <%d> in Update Child Method", SCIPnodeGetType(node)); return SCIP_INVALIDDATA; } /*lint !e788*/ /* append new status line with updated node information to the bakfile */ printTime(visual, stat, FALSE); SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "%s %d %d %c %f %f %d\n", nodeinfo, (int)nodenum, (int)parentnodenum, t, lowerbound, sum, nlpcands); } return SCIP_OKAY; }
/** changes the color of the node to the color of cutoff nodes */ void SCIPvisualCutoffNode( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node, /**< node, that was cut off */ SCIP_Bool infeasible /**< whether the node is infeasible (otherwise exceeded the cutoff bound) */ ) { SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; SCIP_Real lowerbound; size_t nodenum; assert( visual != NULL ); assert( stat != NULL ); assert( node != NULL ); /* check whether output should be created */ if ( visual->vbcfile == NULL && visual->bakfile == NULL ) return; /* visualization is disabled on probing nodes */ if( SCIPnodeGetType(node) == SCIP_NODETYPE_PROBINGNODE ) return; /* get node num from hash map */ nodenum = (size_t)SCIPhashmapGetImage(visual->nodenum, node); assert(nodenum > 0); /* get branching information */ getBranchInfo(node, &branchvar, &branchtype, &branchbound); /* determine lower bound */ if ( set->visual_objextern ) lowerbound = SCIPretransformObj(set->scip, SCIPnodeGetLowerbound(node)); else lowerbound = SCIPnodeGetLowerbound(node); if ( visual->vbcfile != NULL ) { printTime(visual, stat, TRUE); if( branchvar != NULL ) { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t%s [%g,%g] %s %f\\nbound:\\t%f\\nnr:\\t%" SCIP_LONGINT_FORMAT "\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), SCIPvarGetName(branchvar), SCIPvarGetLbLocal(branchvar), SCIPvarGetUbLocal(branchvar), branchtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", branchbound, lowerbound, stat->nnodes); } else { SCIPmessageFPrintInfo(visual->messagehdlr, visual->vbcfile, "I %d \\inode:\\t%d (%p)\\idepth:\\t%d\\nvar:\\t-\\nbound:\\t%f\\nnr:\\t%" SCIP_LONGINT_FORMAT "\n", (int)nodenum, (int)nodenum, node, SCIPnodeGetDepth(node), lowerbound, stat->nnodes); } vbcSetColor(visual, stat, node, SCIP_VBCCOLOR_CUTOFF); } if ( visual->bakfile != NULL ) { size_t parentnodenum; char t = 'M'; /* determine branching type */ if ( branchvar != NULL ) t = (branchtype == SCIP_BOUNDTYPE_LOWER ? 'R' : 'L'); /* get nodenum of parent node from hash map */ parentnodenum = (node->parent != NULL ? (size_t)SCIPhashmapGetImage(visual->nodenum, node->parent) : 0); assert(node->parent == NULL || parentnodenum > 0); printTime(visual, stat, FALSE); if ( infeasible ) SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "infeasible %d %d %c\n", (int)nodenum, (int)parentnodenum, t); else SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "fathomed %d %d %c\n", (int)nodenum, (int)parentnodenum, t); } }
/** changes the color of the node to the color of nodes with a primal solution */ void SCIPvisualFoundSolution( SCIP_VISUAL* visual, /**< visualization information */ SCIP_SET* set, /**< global SCIP settings */ SCIP_STAT* stat, /**< problem statistics */ SCIP_NODE* node, /**< node where the solution was found, or NULL */ SCIP_Bool bettersol, /**< the solution was better than the previous ones */ SCIP_SOL* sol /**< solution that has been found */ ) { if ( visual->vbcfile != NULL ) { if ( node != NULL && set->visual_dispsols ) { if ( SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE ) vbcSetColor(visual, stat, node, SCIP_VBCCOLOR_SOLUTION); } } if ( visual->bakfile != NULL && bettersol ) { SCIP_Real obj; if ( set->visual_objextern ) obj = SCIPgetSolOrigObj(set->scip, sol); else obj = SCIPgetSolTransObj(set->scip, sol); if ( SCIPsolGetHeur(sol) == NULL && node != NULL ) { /* if LP solution was feasible ... */ SCIP_VAR* branchvar; SCIP_BOUNDTYPE branchtype; SCIP_Real branchbound; SCIP_NODE *pnode; size_t parentnodenum; size_t nodenum; char t = 'M'; /* find first parent that is not a probing node */ pnode = node; while ( pnode != NULL && SCIPnodeGetType(pnode) == SCIP_NODETYPE_PROBINGNODE ) pnode = pnode->parent; if ( pnode != NULL ) { /* get node num from hash map */ nodenum = (size_t)SCIPhashmapGetImage(visual->nodenum, pnode); /* get nodenum of parent node from hash map */ parentnodenum = (pnode->parent != NULL ? (size_t)SCIPhashmapGetImage(visual->nodenum, pnode->parent) : 0); assert( pnode->parent == NULL || parentnodenum > 0 ); /* get branching information */ getBranchInfo(pnode, &branchvar, &branchtype, &branchbound); /* determine branching type */ if ( branchvar != NULL ) t = (branchtype == SCIP_BOUNDTYPE_LOWER ? 'R' : 'L'); printTime(visual, stat, FALSE); SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "integer %d %d %c %f\n", (int)nodenum, (int)parentnodenum, t, obj); } } else { printTime(visual, stat, FALSE); SCIPmessageFPrintInfo(visual->messagehdlr, visual->bakfile, "heuristic %f\n", obj); } } }