SCIP

Solving Constraint Integer Programs

reduce_sol.c File Reference

Detailed Description

Reduction solution storage methods for Steiner problems.

Author
Daniel Rehfeldt

This file includes methods to save and retain solutions and sollocal bounds during the reduction process

A list of all interface methods can be found in reduce.h.

Definition in file reduce_sol.c.

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "graph.h"
#include "reduce.h"
#include "heur_tm.h"
#include "solstp.h"
#include "scip/scip.h"
#include "portab.h"
#include "stpvector.h"

Go to the source code of this file.

Data Structures

struct  reduction_local_solution_storage
 
struct  reduction_solution_level
 
struct  reduction_solution_storage
 

Macros

#define REDSOLVAL_UNSET   (-FARAWAY)
 

Typedefs

typedef struct reduction_solution_level REDSOLLEVEL
 

Functions

static void nodesolSetTrivial (const GRAPH *g, int *nodesol)
 
static SCIP_RETCODE nodesolUpdate (SCIP *scip, GRAPH *g, SCIP_Real *solval, PATH *solpath, int *nodesol)
 
static SCIP_RETCODE sollocalInitNodesol (SCIP *scip, int *nodesol_transfer, REDSOLLOCAL *sollocal)
 
static void nodesolGetEdgeSol (const GRAPH *graph, const PATH *solpath, int *edgesol)
 
static SCIP_RETCODE redlevelInit (SCIP *scip, int nnodes, REDSOLLEVEL **redlevel)
 
static void redlevelFree (SCIP *scip, REDSOLLEVEL **redlevel)
 
static SCIP_Bool redlevelIsClean (REDSOLLEVEL *redlevel)
 
static void redlevelClean (SCIP *scip, REDSOLLEVEL *redlevel)
 
static int * redlevelGetNodesol (REDSOLLEVEL *redlevel)
 
static SCIP_RETCODE redlevelInitIncomplete (SCIP *scip, const REDSOL *redsol, REDSOLLEVEL *redlevel)
 
static SCIP_RETCODE redlevelAddLocal (SCIP *scip, const GRAPH *g, REDSOLLEVEL *redlevel, REDSOLLOCAL **redsollocal_out)
 
static int redsolGetNlevels (const REDSOL *redsol)
 
static REDSOLLEVEL * redsolGetTopLevel (const REDSOL *redsol)
 
static REDSOLLEVEL * redsolGetTopParentLevel (const REDSOL *redsol)
 
SCIP_RETCODE reduce_sollocalInit (SCIP *scip, const GRAPH *g, REDSOLLOCAL **sollocal)
 
void reduce_sollocalFree (SCIP *scip, REDSOLLOCAL **sollocal)
 
void reduce_sollocalSetOffset (SCIP_Real offsetnew, REDSOLLOCAL *sollocal)
 
SCIP_RETCODE reduce_sollocalRebuildTry (SCIP *scip, GRAPH *g, REDSOLLOCAL *sollocal)
 
SCIP_Bool reduce_sollocalUsesNodesol (const REDSOLLOCAL *sollocal)
 
SCIP_RETCODE reduce_sollocalUpdateNodesol (SCIP *scip, const int *edgesol, GRAPH *g, REDSOLLOCAL *sollocal)
 
void reduce_sollocalUpdateUpperBound (SCIP_Real ubnew, REDSOLLOCAL *sollocal)
 
SCIP_Real reduce_sollocalGetUpperBound (const REDSOLLOCAL *sollocal)
 
int * reduce_sollocalGetSolnode (REDSOLLOCAL *sollocal)
 
SCIP_Real reduce_sollocalGetUpperBoundWithOffset (const REDSOLLOCAL *sollocal)
 
SCIP_Bool reduce_sollocalHasUpperBound (const REDSOLLOCAL *sollocal)
 
SCIP_RETCODE reduce_solInit (SCIP *scip, const GRAPH *g, SCIP_Bool useNodeSol, REDSOL **redsol)
 
SCIP_RETCODE reduce_solInitLocal (SCIP *scip, const GRAPH *g, REDSOL *redsol, REDSOLLOCAL **redsollocal_out)
 
void reduce_solFinalizeLocal (SCIP *scip, const GRAPH *g, REDSOL *redsol)
 
void reduce_solReInitLocal (const GRAPH *g, REDSOL *redsol)
 
void reduce_solFree (SCIP *scip, REDSOL **redsol)
 
void reduce_solPack (const GRAPH *g, const int *nodes_old2packed, int nnodes_packed, REDSOL *redsol)
 
SCIP_RETCODE reduce_solLevelAdd (SCIP *scip, const GRAPH *g, REDSOL *redsol)
 
SCIP_RETCODE reduce_solLevelTopUpdate (SCIP *scip, const GRAPH *subgraph, REDSOL *redsol)
 
void reduce_solLevelTopRemove (SCIP *scip, REDSOL *redsol)
 
void reduce_solLevelTopFinalize (SCIP *scip, GRAPH *g, REDSOL *redsol)
 
void reduce_solLevelTopClean (SCIP *scip, REDSOL *redsol)
 
void reduce_solLevelTopTransferSolBack (const int *nodemap_subToOrg, REDSOL *redsol)
 
SCIP_RETCODE reduce_solLevelTopTransferSolTo (const int *nodemap_orgToTop, REDSOL *redsol)
 
void reduce_solSetOffset (SCIP_Real offsetnew, REDSOL *redsol)
 
SCIP_Real reduce_solGetOffset (const REDSOL *redsol)
 
SCIP_RETCODE reduce_solAddNodesol (const GRAPH *g, const int *nodesol, REDSOL *redsol)
 
void reduce_solGetNodesol (const GRAPH *g, REDSOL *redsol, int *nodesol)
 
SCIP_RETCODE reduce_solGetEdgesol (SCIP *scip, GRAPH *g, REDSOL *redsol, SCIP_Real *solval, int *edgesol)
 
SCIP_Bool reduce_solUsesNodesol (const REDSOL *redsol)
 
const int * reduce_solGetNodesolPointer (const REDSOL *redsol)
 
SCIP_Real reduce_solGetUpperBoundWithOffset (const REDSOL *redsol)
 
SCIP_Real * reduce_solGetOffsetPointer (REDSOL *redsol)
 

Macro Definition Documentation

◆ REDSOLVAL_UNSET

Typedef Documentation

◆ REDSOLLEVEL

single level representation (needed for decomposition of problem graph)

Function Documentation

◆ nodesolSetTrivial()

static void nodesolSetTrivial ( const GRAPH *  g,
int *  nodesol 
)
static

updates node solution

Parameters
ggraph data structure
nodesolsolution array to be filled

Definition at line 87 of file reduce_sol.c.

References CONNECT, graph_get_nNodes(), Is_term, reduction_local_solution_storage::nnodes, GRAPH::term, GRAPH::terms, and UNKNOWN.

Referenced by reduce_solFinalizeLocal().

◆ nodesolUpdate()

static SCIP_RETCODE nodesolUpdate ( SCIP *  scip,
GRAPH *  g,
SCIP_Real *  solval,
PATH *  solpath,
int *  nodesol 
)
static

updates node solution

Parameters
scipSCIP data structure
ggraph data structure
solvalFARAWAY if no valid solution build
solpathpath entry per node
nodesolsolution array to be filled

Definition at line 113 of file reduce_sol.c.

References BMScopyMemoryArray, GRAPH::cost, graph_get_nNodes(), graph_pc_isPcMw(), graph_printInfoReduced(), graph_typeIsSpgLike(), reduction_local_solution_storage::nnodes, reduction_local_solution_storage::nodesol, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPStpHeurTMBuildTree(), SCIPStpHeurTMBuildTreePcMw(), and TRUE.

Referenced by reduce_solGetEdgesol(), reduce_sollocalRebuildTry(), and reduce_sollocalUpdateNodesol().

◆ sollocalInitNodesol()

static SCIP_RETCODE sollocalInitNodesol ( SCIP *  scip,
int *  nodesol_transfer,
REDSOLLOCAL *  sollocal 
)
static

initializes node solution

Parameters
scipSCIP data structure
nodesol_transfersolution to be moved or NULL
sollocalsolution

Definition at line 166 of file reduce_sol.c.

References reduction_local_solution_storage::nnodes, reduction_local_solution_storage::nodesol, reduction_local_solution_storage::nodesol_ub, reduction_local_solution_storage::nodesol_use, REDSOLVAL_UNSET, SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, TRUE, and UNKNOWN.

Referenced by redlevelAddLocal().

◆ nodesolGetEdgeSol()

static void nodesolGetEdgeSol ( const GRAPH *  graph,
const PATH *  solpath,
int *  edgesol 
)
static

gets edge solution after nodesolUpdate call

Parameters
graphgraph
solpathstores solution
edgesolsolution array to be filled

Definition at line 202 of file reduce_sol.c.

References CONNECT, shortest_path::edge, graph_get_nEdges(), graph_get_nNodes(), reduction_local_solution_storage::nnodes, and UNKNOWN.

Referenced by reduce_solGetEdgesol().

◆ redlevelInit()

◆ redlevelFree()

static void redlevelFree ( SCIP *  scip,
REDSOLLEVEL **  redlevel 
)
static

◆ redlevelIsClean()

◆ redlevelClean()

static void redlevelClean ( SCIP *  scip,
REDSOLLEVEL *  redlevel 
)
static

◆ redlevelGetNodesol()

static int* redlevelGetNodesol ( REDSOLLEVEL *  redlevel)
static

gets node solution

Parameters
redlevelto be cleaned

Definition at line 325 of file reduce_sol.c.

References reduction_solution_level::nodesol, reduction_solution_level::redsollocal, and reduce_sollocalGetSolnode().

Referenced by reduce_solLevelTopTransferSolBack(), and reduce_solLevelTopTransferSolTo().

◆ redlevelInitIncomplete()

static SCIP_RETCODE redlevelInitIncomplete ( SCIP *  scip,
const REDSOL *  redsol,
REDSOLLEVEL *  redlevel 
)
static

initializes incomplete info

Parameters
scipSCIP data structure
redsolreduction solution
redlevelto be initialized

Definition at line 342 of file reduce_sol.c.

References EQ, reduction_solution_level::nnodes, SCIP_OKAY, SCIPdebugMessage, and reduction_solution_level::solval_incomplete.

Referenced by reduce_solLevelAdd().

◆ redlevelAddLocal()

static SCIP_RETCODE redlevelAddLocal ( SCIP *  scip,
const GRAPH *  g,
REDSOLLEVEL *  redlevel,
REDSOLLOCAL **  redsollocal_out 
)
static

adds local solution

Parameters
scipSCIP data structure
ggraph data structure
redlevellevel
redsollocal_outpointer to newly initialized local

Definition at line 362 of file reduce_sol.c.

References reduction_solution_level::nnodes, reduction_solution_level::nodesol_transfer, reduction_solution_level::nodesol_use, NULL, reduction_solution_level::redsollocal, reduce_sollocalInit(), SCIP_CALL, SCIP_OKAY, and sollocalInitNodesol().

Referenced by reduce_solInitLocal().

◆ redsolGetNlevels()

◆ redsolGetTopLevel()

◆ redsolGetTopParentLevel()

static REDSOLLEVEL* redsolGetTopParentLevel ( const REDSOL *  redsol)
static

gets parent of top level

Parameters
redsolsolution

Definition at line 429 of file reduce_sol.c.

References redsolGetNlevels().

Referenced by reduce_solLevelTopTransferSolBack(), and reduce_solLevelTopTransferSolTo().

◆ reduce_sollocalInit()

◆ reduce_sollocalFree()

void reduce_sollocalFree ( SCIP *  scip,
REDSOLLOCAL **  sollocal 
)

frees

Parameters
scipSCIP data structure
sollocalto free

Definition at line 472 of file reduce_sol.c.

References SCIPfreeMemory, and SCIPfreeMemoryArrayNull.

Referenced by redlevelFree(), reduce_dc(), reduce_hc(), and reduce_solFinalizeLocal().

◆ reduce_sollocalSetOffset()

void reduce_sollocalSetOffset ( SCIP_Real  offsetnew,
REDSOLLOCAL *  sollocal 
)

◆ reduce_sollocalRebuildTry()

◆ reduce_sollocalUsesNodesol()

SCIP_Bool reduce_sollocalUsesNodesol ( const REDSOLLOCAL *  sollocal)

updates

Parameters
sollocalsollocal

Definition at line 554 of file reduce_sol.c.

References reduction_local_solution_storage::nodesol_use.

Referenced by redbaseGetSolnode(), reduce_da(), reduce_daPcMw(), reduce_sollocalGetSolnode(), and reduce_sollocalUpdateNodesol().

◆ reduce_sollocalUpdateNodesol()

SCIP_RETCODE reduce_sollocalUpdateNodesol ( SCIP *  scip,
const int *  edgesol,
GRAPH *  g,
REDSOLLOCAL *  sollocal 
)

◆ reduce_sollocalUpdateUpperBound()

void reduce_sollocalUpdateUpperBound ( SCIP_Real  ubnew,
REDSOLLOCAL *  sollocal 
)

sets new sollocal bound if better than old one

Parameters
ubnewnew upper bound, not including offset!
sollocalsollocal

Definition at line 610 of file reduce_sol.c.

References FARAWAY, GE, LE, reduction_local_solution_storage::offset, reduction_local_solution_storage::primalbound, SCIP_Real, and SCIPdebugMessage.

Referenced by reduce_da(), reduce_daPcMw(), reduce_solFinalizeLocal(), and reduce_solLevelTopFinalize().

◆ reduce_sollocalGetUpperBound()

SCIP_Real reduce_sollocalGetUpperBound ( const REDSOLLOCAL *  sollocal)

gets upper bound; not including (last set) offset

Parameters
sollocalsollocal

Definition at line 633 of file reduce_sol.c.

References EQ, FARAWAY, GE_FEAS, MAX, reduction_local_solution_storage::offset, reduction_local_solution_storage::primalbound, and SCIPdebugMessage.

Referenced by redLoopInnerStp(), reduce_da(), reduce_daPcMw(), and reduce_impliedProfitBasedRpc().

◆ reduce_sollocalGetSolnode()

int* reduce_sollocalGetSolnode ( REDSOLLOCAL *  sollocal)

◆ reduce_sollocalGetUpperBoundWithOffset()

SCIP_Real reduce_sollocalGetUpperBoundWithOffset ( const REDSOLLOCAL *  sollocal)

gets upper bound; including (last set) offset

Parameters
sollocalsollocal

Definition at line 664 of file reduce_sol.c.

References reduction_local_solution_storage::primalbound.

Referenced by reduce_solFinalizeLocal().

◆ reduce_sollocalHasUpperBound()

SCIP_Bool reduce_sollocalHasUpperBound ( const REDSOLLOCAL *  sollocal)

do we have a (non-trivial) primal bound?

Parameters
sollocalsollocal

Definition at line 675 of file reduce_sol.c.

References EQ, FARAWAY, LE, and reduction_local_solution_storage::primalbound.

Referenced by reduce_solFinalizeLocal().

◆ reduce_solInit()

SCIP_RETCODE reduce_solInit ( SCIP *  scip,
const GRAPH *  g,
SCIP_Bool  useNodeSol,
REDSOL **  redsol 
)

◆ reduce_solInitLocal()

SCIP_RETCODE reduce_solInitLocal ( SCIP *  scip,
const GRAPH *  g,
REDSOL *  redsol,
REDSOLLOCAL **  redsollocal_out 
)

adds local for given level; call before reduction loop

Parameters
scipSCIP data structure
ggraph data structure
redsolreduction solution
redsollocal_outpointer to newly initialized local

Definition at line 717 of file reduce_sol.c.

References redlevelAddLocal(), redsolGetNlevels(), SCIP_CALL, and SCIP_OKAY.

Referenced by reduce_redLoopMw(), reduce_redLoopPc(), reduce_redLoopStp(), testBiconnectedDecomposition(), testBiconnectedDecomposition2(), and testBiconnectedDecomposition3().

◆ reduce_solFinalizeLocal()

◆ reduce_solReInitLocal()

void reduce_solReInitLocal ( const GRAPH *  g,
REDSOL *  redsol 
)

reinitalizes local after it has been finished

Parameters
ggraph data structure
redsolreduction solution

Definition at line 793 of file reduce_sol.c.

References GRAPH::knots, reduction_solution_level::nnodes, reduction_solution_level::nodesol, reduction_solution_level::nodesol_transfer, reduction_solution_level::nodesol_ub, NULL, redsolGetTopLevel(), REDSOLVAL_UNSET, and reduction_solution_level::solval_postred.

Referenced by reduce_exec().

◆ reduce_solFree()

◆ reduce_solPack()

void reduce_solPack ( const GRAPH *  g,
const int *  nodes_old2packed,
int  nnodes_packed,
REDSOL *  redsol 
)

packs solution

Parameters
ggraph data structure
nodes_old2packedmap to packed node IDs
nnodes_packednumber of packed nodes
redsolsollocal

Definition at line 846 of file reduce_sol.c.

References graph_get_nNodes(), graph_pc_isPcMw(), reduction_local_solution_storage::nnodes, reduction_solution_level::nnodes, reduction_local_solution_storage::nodesol, and reduction_solution_level::nodesol.

Referenced by graph_pack().

◆ reduce_solLevelAdd()

SCIP_RETCODE reduce_solLevelAdd ( SCIP *  scip,
const GRAPH *  g,
REDSOL *  redsol 
)

adds level

Parameters
scipSCIP data structure
ggraph data structure
redsolsollocal

Definition at line 897 of file reduce_sol.c.

References EQ, reduction_solution_level::nodesol_use, redlevelInit(), redlevelInitIncomplete(), redsolGetNlevels(), redsolGetTopLevel(), SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, and StpVecPushBack.

Referenced by decomposeReduce().

◆ reduce_solLevelTopUpdate()

SCIP_RETCODE reduce_solLevelTopUpdate ( SCIP *  scip,
const GRAPH *  subgraph,
REDSOL *  redsol 
)

initializes level with given (sub) graph

Parameters
scipSCIP data structure
subgraphgraph data structure
redsolreduction solution

Definition at line 922 of file reduce_sol.c.

References graph_get_nNodes(), reduction_local_solution_storage::nnodes, reduction_solution_level::nnodes, redlevelIsClean(), redsolGetTopLevel(), and SCIP_OKAY.

Referenced by decomposeReduceSubDoIt().

◆ reduce_solLevelTopRemove()

void reduce_solLevelTopRemove ( SCIP *  scip,
REDSOL *  redsol 
)

removes top level

Parameters
scipSCIP data structure
redsolreduction solution

Definition at line 940 of file reduce_sol.c.

References redlevelFree(), redsolGetNlevels(), and StpVecPopBack.

◆ reduce_solLevelTopFinalize()

void reduce_solLevelTopFinalize ( SCIP *  scip,
GRAPH *  g,
REDSOL *  redsol 
)

finalizes top level; also removes the level!

Parameters
scipSCIP data structure
ggraph data structure
redsolsollocal

Definition at line 956 of file reduce_sol.c.

References redlevelFree(), redsolGetNlevels(), redsolGetTopLevel(), reduction_solution_level::redsollocal, reduce_sollocalSetOffset(), reduce_sollocalUpdateUpperBound(), SCIPdebugMessage, reduction_solution_level::solval_incomplete, and StpVecPopBack.

Referenced by decomposeReduce().

◆ reduce_solLevelTopClean()

void reduce_solLevelTopClean ( SCIP *  scip,
REDSOL *  redsol 
)

removes level

Parameters
scipSCIP data structure
redsolsollocal

Definition at line 997 of file reduce_sol.c.

References redlevelClean(), and redsolGetNlevels().

Referenced by decomposeReduceSubDoIt().

◆ reduce_solLevelTopTransferSolBack()

◆ reduce_solLevelTopTransferSolTo()

SCIP_RETCODE reduce_solLevelTopTransferSolTo ( const int *  nodemap_orgToTop,
REDSOL *  redsol 
)

◆ reduce_solSetOffset()

void reduce_solSetOffset ( SCIP_Real  offsetnew,
REDSOL *  redsol 
)

sets offset

Parameters
offsetnewnew offset
redsolsolution

Definition at line 1124 of file reduce_sol.c.

References GE.

Referenced by decomposeReduceSubDoIt().

◆ reduce_solGetOffset()

SCIP_Real reduce_solGetOffset ( const REDSOL *  redsol)

◆ reduce_solAddNodesol()

SCIP_RETCODE reduce_solAddNodesol ( const GRAPH *  g,
const int *  nodesol,
REDSOL *  redsol 
)

adds (and possibly overwrites) nodesol

Parameters
ggraph data structure
nodesolincoming solution
redsolsolution

Definition at line 1150 of file reduce_sol.c.

References BMScopyMemoryArray, GRAPH::knots, reduction_solution_level::nnodes, reduction_solution_level::nodesol_transfer, reduction_solution_level::nodesol_ub, redsolGetNlevels(), SCIP_CALL, SCIP_OKAY, and SCIPallocMemoryArray.

Referenced by reduceExact(), and SCIPStpHeurPruneRun().

◆ reduce_solGetNodesol()

void reduce_solGetNodesol ( const GRAPH *  g,
REDSOL *  redsol,
int *  nodesol 
)

gets

Parameters
ggraph data structure
redsolsolution
nodesolsolution array to be filled

Definition at line 1176 of file reduce_sol.c.

References BMScopyMemoryArray, GRAPH::knots, reduction_solution_level::nnodes, reduction_solution_level::nodesol, and redsolGetNlevels().

Referenced by reduceExact(), and SCIPStpHeurPruneRun().

◆ reduce_solGetEdgesol()

SCIP_RETCODE reduce_solGetEdgesol ( SCIP *  scip,
GRAPH *  g,
REDSOL *  redsol,
SCIP_Real *  solval,
int *  edgesol 
)

gets edge solution, if available, and solution value

Parameters
scipSCIP data structure
ggraph data structure
redsolsolution
solvalFARAWAY if no solution available
edgesolsolution array to be filled

Definition at line 1197 of file reduce_sol.c.

References FARAWAY, graph_get_nNodes(), GRAPH::knots, LT, reduction_local_solution_storage::nnodes, reduction_solution_level::nodesol, reduction_solution_level::nodesol_ub, nodesolGetEdgeSol(), nodesolUpdate(), SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, and SCIPfreeBufferArray.

Referenced by addRedsol(), and computeReducedProbSolution().

◆ reduce_solUsesNodesol()

SCIP_Bool reduce_solUsesNodesol ( const REDSOL *  redsol)

is node solution in use?

Parameters
redsolsolution

Definition at line 1236 of file reduce_sol.c.

Referenced by computeReducedProbSolution(), redbaseGetSolnode(), and reduce_solGetNodesolPointer().

◆ reduce_solGetNodesolPointer()

const int* reduce_solGetNodesolPointer ( const REDSOL *  redsol)

gets

Parameters
redsolsolution

Definition at line 1248 of file reduce_sol.c.

References reduction_solution_level::nodesol, redsolGetNlevels(), redsolGetTopLevel(), and reduce_solUsesNodesol().

◆ reduce_solGetUpperBoundWithOffset()

SCIP_Real reduce_solGetUpperBoundWithOffset ( const REDSOL *  redsol)

◆ reduce_solGetOffsetPointer()