Scippy

SCIP

Solving Constraint Integer Programs

probdata_stp.c File Reference

Detailed Description

Minimum cut routine for Steiner problems.

Problem data for Steiner problems.

Author
Gerald Gamrath
Thorsten Koch
Daniel Rehfeldt

This file implements a graph minimum cut routine for Steiner problems. For more details see Graph minimum cut routine page.

Author
Gerald Gamrath
Thorsten Koch
Michael Winkler
Daniel Rehfeldt

This file implements the problem data for Steiner problems. For more details see Main problem data page.

Definition in file probdata_stp.c.

#include <string.h>
#include "probdata_stp.h"
#include <stdio.h>
#include "scip/scip.h"
#include "cons_stp.h"
#include "grph.h"
#include "scip/cons_linear.h"
#include "scip/cons_setppc.h"
#include "scip/misc.h"
#include "scip/struct_misc.h"

Go to the source code of this file.

Macros

#define CENTER_OK   0
 
#define CENTER_DEG   1
 
#define CENTER_SUM   2
 
#define CENTER_MIN   3
 
#define CENTER_ALL   4
 
#define MODE_CUT   0
 
#define MODE_FLOW   1
 
#define MODE_PRICE   2
 
#define CONS_ALWAYS   1
 
#define CONS_SPECIFIC   2
 
#define FLOWB   FALSE
 
#define SYM_CONS_LIMIT   20000
 
#define CYC_CONS_LIMIT   15000
 

Functions

Local methods
static SCIP_RETCODE central_terminal (SCIP *scip, GRAPH *g, int *central_term, int centertype)
 
static SCIP_RETCODE probdataCreate (SCIP *scip, SCIP_PROBDATA **probdata, GRAPH *graph)
 
static SCIP_RETCODE probdataFree (SCIP *scip, SCIP_PROBDATA **probdata)
 
static SCIP_RETCODE probdataPrintGraph (GRAPH *graph, const char *filename, SCIP_Bool *edgemark)
 
static SCIP_RETCODE createHopConstraint (SCIP *scip, SCIP_PROBDATA *probdata)
 
static SCIP_RETCODE createDegreeConstraints (SCIP *scip, SCIP_PROBDATA *probdata)
 
static SCIP_RETCODE createPrizeConstraints (SCIP *scip, SCIP_PROBDATA *probdata)
 
static SCIP_RETCODE createConstraints (SCIP *scip, SCIP_PROBDATA *probdata)
 
static SCIP_RETCODE createVariables (SCIP *scip, SCIP_PROBDATA *probdata, SCIP_Real offset)
 
Callback methods of problem data
static SCIP_DECL_PROBCOPY (probcopyStp)
 
static SCIP_DECL_PROBDELORIG (probdelorigStp)
 
static SCIP_DECL_PROBTRANS (probtransStp)
 
static SCIP_DECL_PROBEXITSOL (probexitsolStp)
 
static SCIP_DECL_PROBDELTRANS (probdeltransStp)
 
Interface methods
SCIP_RETCODE SCIPprobdataCreate (SCIP *scip, const char *filename)
 
void SCIPprobdataSetGraph (SCIP_PROBDATA *probdata, GRAPH *graph)
 
GRAPHSCIPprobdataGetGraph (SCIP_PROBDATA *probdata)
 
void SCIPprobdataSetOffset (SCIP_PROBDATA *probdata, SCIP_Real offset)
 
int SCIPprobdataGetNVars (SCIP *scip)
 
SCIP_VAR ** SCIPprobdataGetVars (SCIP *scip)
 
int SCIPprobdataGetNLayers (SCIP *scip)
 
int SCIPprobdataGetNEdges (SCIP *scip)
 
int SCIPprobdataGetNTerms (SCIP *scip)
 
int SCIPprobdataGetRNTerms (SCIP *scip)
 
int SCIPprobdataGetRoot (SCIP *scip)
 
SCIP_Real SCIPprobdataGetOffset (SCIP *scip)
 
SCIP_VAR * SCIPprobdataGetedgeVarByIndex (SCIP *scip, int idx)
 
SCIP_Real * SCIPprobdataGetXval (SCIP *scip, SCIP_SOL *sol)
 
SCIP_CONS ** SCIPprobdataGetEdgeConstraints (SCIP *scip)
 
SCIP_CONS ** SCIPprobdataGetPathConstraints (SCIP *scip)
 
int * SCIPprobdataGetRTerms (SCIP *scip)
 
SCIP_VAR ** SCIPprobdataGetEdgeVars (SCIP *scip)
 
SCIP_Bool SCIPprobdataIsBigt (SCIP *scip)
 
SCIP_RETCODE SCIPprobdataPrintGraph (SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool printsol)
 
SCIP_RETCODE SCIPprobdataWriteIntermediateSolution (SCIP *scip)
 
SCIP_RETCODE SCIPprobdataWriteSolution (SCIP *scip, FILE *file)
 
void SCIPprobdataWriteLogLine (SCIP *scip, const char *formatstr,...)
 
SCIP_RETCODE SCIPprobdataAddNewSol (SCIP *scip, SCIP_Real *nval, SCIP_SOL *sol, SCIP_HEUR *heur, SCIP_Bool *success)
 
SCIP_RETCODE SCIPprobdataPrintGraph2 (const GRAPH *graph, const char *filename, SCIP_Bool *edgemark)
 
int SCIPprobdataGetType (SCIP *scip)
 
SCIP_RETCODE SCIPprobdataWriteLogfileEnd (SCIP *scip)
 
void SCIPprobdataSetDualBound (SCIP *scip, SCIP_Real dual)
 
void SCIPprobdataSetNSolvers (SCIP *scip, int nSolvers)
 

Macro Definition Documentation

#define CENTER_ALL   4

find the minimum distance sum to all knots

Definition at line 56 of file probdata_stp.c.

Referenced by central_terminal().

#define CENTER_DEG   1

find maximum degree

Definition at line 53 of file probdata_stp.c.

Referenced by central_terminal(), and SCIPprobdataCreate().

#define CENTER_MIN   3

find the minimum largest distance

Definition at line 55 of file probdata_stp.c.

Referenced by central_terminal().

#define CENTER_OK   0

do nothing

Definition at line 52 of file probdata_stp.c.

Referenced by central_terminal().

#define CENTER_SUM   2

find the minimum distance sum

Definition at line 54 of file probdata_stp.c.

Referenced by central_terminal().

#define CONS_ALWAYS   1

always use (respective) constraints

Definition at line 62 of file probdata_stp.c.

Referenced by SCIPprobdataCreate().

#define CONS_SPECIFIC   2

use (respective) constraints depending on the problem instance

Definition at line 63 of file probdata_stp.c.

Referenced by SCIPprobdataCreate().

#define CYC_CONS_LIMIT   15000

maximum number of symmetry inequalities for PCSPG

Definition at line 68 of file probdata_stp.c.

Referenced by SCIPprobdataCreate().

#define FLOWB   FALSE

Definition at line 65 of file probdata_stp.c.

#define MODE_FLOW   1
#define MODE_PRICE   2
#define SYM_CONS_LIMIT   20000

maximum number of symmetry inequalities for MWCSP and PCSPG

Definition at line 67 of file probdata_stp.c.

Referenced by SCIPprobdataCreate().

Function Documentation

static SCIP_RETCODE central_terminal ( SCIP *  scip,
GRAPH g,
int *  central_term,
int  centertype 
)
static
Parameters
scipSCIP data structure
ggraph data structure
central_termpointer to store the selected (terminal) vertex
centertypetype of root selection

Definition at line 135 of file probdata_stp.c.

References CENTER_ALL, CENTER_DEG, CENTER_MIN, CENTER_OK, CENTER_SUM, shortest_path::dist, GRAPH::edges, FARAWAY, FSP_MODE, GRAPH::grad, graph_path_exec(), Is_term, GRAPH::knots, GRAPH::layers, GRAPH::mark, GRAPH::source, GRAPH::term, and TRUE.

Referenced by SCIPprobdataCreate().

static SCIP_RETCODE createConstraints ( SCIP *  scip,
SCIP_PROBDATA *  probdata 
)
static

create constraints (in Flow or Price Mode)

Parameters
scipSCIP data structure
probdataproblem data

Definition at line 722 of file probdata_stp.c.

References FALSE, SCIP_ProbData::graph, MODE_CUT, MODE_FLOW, MODE_PRICE, SCIP_ProbData::nedges, SCIP_ProbData::nnodes, SCIP_ProbData::realnterms, GRAPH::source, GRAPH::term, and TRUE.

Referenced by SCIPprobdataCreate().

static SCIP_RETCODE createDegreeConstraints ( SCIP *  scip,
SCIP_PROBDATA *  probdata 
)
static

create (node-) degree constraints (cut mode only)

Parameters
scipSCIP data structure
probdataproblem data

Definition at line 546 of file probdata_stp.c.

References FALSE, SCIP_ProbData::graph, GRAPH::maxdeg, SCIP_ProbData::nnodes, and TRUE.

Referenced by SCIPprobdataCreate().

static SCIP_RETCODE createHopConstraint ( SCIP *  scip,
SCIP_PROBDATA *  probdata 
)
static

create (edge-) HOP constraint (cut mode only)

Parameters
scipSCIP data structure
probdataproblem data

Definition at line 518 of file probdata_stp.c.

References FALSE, SCIP_ProbData::graph, GRAPH::hoplimit, and TRUE.

Referenced by SCIPprobdataCreate().

static SCIP_RETCODE createPrizeConstraints ( SCIP *  scip,
SCIP_PROBDATA *  probdata 
)
static

create Prize constraints (cut mode only)

Parameters
scipSCIP data structure
probdataproblem data

Definition at line 581 of file probdata_stp.c.

References GRAPH::edges, FALSE, SCIP_ProbData::graph, GRAPH::head, GRAPH::knots, SCIP_ProbData::nedges, SCIP_ProbData::nnonterms, SCIP_ProbData::realnterms, GRAPH::source, STP_PRIZE_COLLECTING, STP_ROOTED_PRIZE_COLLECTING, GRAPH::stp_type, GRAPH::terms, and TRUE.

Referenced by SCIPprobdataCreate().

static SCIP_RETCODE createVariables ( SCIP *  scip,
SCIP_PROBDATA *  probdata,
SCIP_Real  offset 
)
static
static SCIP_RETCODE probdataCreate ( SCIP *  scip,
SCIP_PROBDATA **  probdata,
GRAPH graph 
)
static

creates problem data

Parameters
scipSCIP data structure
probdatapointer to problem data
graphgraph data structure

Definition at line 267 of file probdata_stp.c.

References FALSE, SCIP_ProbData::graph, GRAPH::stp_type, and STP_UNDIRECTED.

Referenced by SCIP_DECL_PROBCOPY(), SCIP_DECL_PROBTRANS(), and SCIPprobdataCreate().

static SCIP_RETCODE probdataFree ( SCIP *  scip,
SCIP_PROBDATA **  probdata 
)
static

frees the memory of the given problem data

Parameters
scipSCIP data structure
probdatapointer to problem data

Definition at line 301 of file probdata_stp.c.

References MODE_CUT, MODE_FLOW, MODE_PRICE, STP_DEG_CONS, STP_MAX_NODE_WEIGHT, STP_PRIZE_COLLECTING, and STP_ROOTED_PRIZE_COLLECTING.

Referenced by SCIP_DECL_PROBDELORIG(), and SCIP_DECL_PROBDELTRANS().

static SCIP_RETCODE probdataPrintGraph ( GRAPH graph,
const char *  filename,
SCIP_Bool *  edgemark 
)
static

print graph (in undirected form) in GML format

Parameters
graphGraph to be printed
filenameName of the output file
edgemarkArray of (undirected) edges to highlight

Definition at line 427 of file probdata_stp.c.

References GRAPH::cost, GRAPH::edges, FALSE, GRAPH::head, GRAPH::knots, GRAPH::source, GRAPH::tail, and GRAPH::term.

Referenced by SCIPprobdataCreate(), and SCIPprobdataPrintGraph().

static SCIP_DECL_PROBCOPY ( probcopyStp  )
static
static SCIP_DECL_PROBDELORIG ( probdelorigStp  )
static

frees user data of original problem (called when the original problem is freed)

Definition at line 1576 of file probdata_stp.c.

References graph_free(), graph_mincut_exit(), graph_path_exit(), MODE_CUT, probdataFree(), and TRUE.

static SCIP_DECL_PROBDELTRANS ( probdeltransStp  )
static

frees user data of transformed problem (called when the transformed problem is freed)

Definition at line 1829 of file probdata_stp.c.

References probdataFree().

static SCIP_DECL_PROBEXITSOL ( probexitsolStp  )
static
static SCIP_DECL_PROBTRANS ( probtransStp  )
static

creates user data of transformed problem by transforming the original user problem data (called after problem was transformed)

Definition at line 1601 of file probdata_stp.c.

References MODE_CUT, MODE_FLOW, MODE_PRICE, probdataCreate(), STP_DEG_CONS, STP_MAX_NODE_WEIGHT, STP_PRIZE_COLLECTING, and STP_ROOTED_PRIZE_COLLECTING.

SCIP_RETCODE SCIPprobdataAddNewSol ( SCIP *  scip,
SCIP_Real *  nval,
SCIP_SOL *  sol,
SCIP_HEUR *  heur,
SCIP_Bool *  success 
)

add new solution

Parameters
scipSCIP data structure
nvalarray [0..nvars], nval[v] = 1 if node v is in the solution, nval[v] = 0 if not
solthe new solution
heurheuristic data
successdenotes whether the new solution has been successfully added

Definition at line 2934 of file probdata_stp.c.

References GRAPH::cost, EAT_LAST, shortest_path::edge, SCIP_ProbData::edgevars, FALSE, FSP_MODE, SCIP_ProbData::graph, graph_path_exec(), GRAPH::ieat, GRAPH::inpbeg, Is_term, GRAPH::knots, GRAPH::mark, MODE_CUT, MODE_FLOW, MODE_PRICE, SCIP_ProbData::nedges, SCIP_ProbData::nvars, SCIP_ProbData::realnterms, GRAPH::source, STP_MAX_NODE_WEIGHT, STP_PRIZE_COLLECTING, GRAPH::stp_type, GRAPH::tail, GRAPH::term, and TRUE.

Referenced by SCIP_DECL_HEUREXEC().

SCIP_CONS** SCIPprobdataGetEdgeConstraints ( SCIP *  scip)

returns all edge constraints

Parameters
scipSCIP data structure

Definition at line 2452 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT().

SCIP_VAR* SCIPprobdataGetedgeVarByIndex ( SCIP *  scip,
int  idx 
)

returns the variable for a given index

Parameters
scipSCIP data structure
idxindex of the edge

Definition at line 2407 of file probdata_stp.c.

SCIP_VAR** SCIPprobdataGetEdgeVars ( SCIP *  scip)

returns the array with all edge variables

Parameters
scipSCIP data structure

Definition at line 2496 of file probdata_stp.c.

Referenced by buildsolgraph(), SCIP_DECL_BRANCHEXECLP(), and selectBranchingVertex().

int SCIPprobdataGetNEdges ( SCIP *  scip)

returns the number of edges

Parameters
scipSCIP data structure

Definition at line 2326 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT(), and SCIP_DECL_PRICERINITSOL().

int SCIPprobdataGetNLayers ( SCIP *  scip)

returns the number of layers

Parameters
scipSCIP data structure

Definition at line 2311 of file probdata_stp.c.

int SCIPprobdataGetNTerms ( SCIP *  scip)

returns the number of terminals

Parameters
scipSCIP data structure

Definition at line 2341 of file probdata_stp.c.

int SCIPprobdataGetNVars ( SCIP *  scip)

returns the number of variables

Parameters
scipSCIP data structure

Definition at line 2281 of file probdata_stp.c.

Referenced by SCIP_DECL_CONSLOCK(), and SCIP_DECL_HEUREXEC().

SCIP_Real SCIPprobdataGetOffset ( SCIP *  scip)

returns offset of the problem

Parameters
scipSCIP data structure

Definition at line 2391 of file probdata_stp.c.

Referenced by SCIP_DECL_EVENTEXEC(), SCIP_DECL_HEUREXEC(), SCIP_DECL_READERWRITE(), and SCIPdualAscentPcStp().

SCIP_CONS** SCIPprobdataGetPathConstraints ( SCIP *  scip)

returns all path constraints

Parameters
scipSCIP data structure

Definition at line 2466 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT().

int SCIPprobdataGetRNTerms ( SCIP *  scip)

returns the number of terminals without the root node

Parameters
scipSCIP data structure

Definition at line 2356 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT(), and SCIP_DECL_PRICERINITSOL().

int SCIPprobdataGetRoot ( SCIP *  scip)

returns root

Parameters
scipSCIP data structure

Definition at line 2371 of file probdata_stp.c.

References SCIP_ProbData::graph, and GRAPH::source.

Referenced by SCIP_DECL_PRICERINIT().

int* SCIPprobdataGetRTerms ( SCIP *  scip)

returns the array with all variables

Parameters
scipSCIP data structure

Definition at line 2481 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT().

int SCIPprobdataGetType ( SCIP *  scip)

returns problem type

Parameters
scipSCIP data structure

Definition at line 3287 of file probdata_stp.c.

Referenced by SCIP_DECL_EVENTEXEC().

SCIP_VAR** SCIPprobdataGetVars ( SCIP *  scip)

returns the array with all variables

Parameters
scipSCIP data structure

Definition at line 2296 of file probdata_stp.c.

Referenced by cut_add(), hcrcbound_reduce(), SCIP_DECL_CONSLOCK(), SCIP_DECL_HEUREXEC(), SCIP_DECL_PROPEXEC(), SCIPdualAscentPcStp(), SCIPdualAscentStp(), and sep_flow().

SCIP_Real* SCIPprobdataGetXval ( SCIP *  scip,
SCIP_SOL *  sol 
)

returns the LP solution values

Parameters
scipSCIP data structure
solsolution to get values from

Definition at line 2424 of file probdata_stp.c.

References SCIP_ProbData::nedges.

Referenced by SCIP_DECL_CONSCHECK(), SCIP_DECL_CONSENFOLP(), SCIP_DECL_CONSENFOPS(), SCIP_DECL_HEUREXEC(), sep_2cut(), and sep_flow().

SCIP_Bool SCIPprobdataIsBigt ( SCIP *  scip)

returns if 'T' model is being used

Parameters
scipSCIP data structure

Definition at line 2511 of file probdata_stp.c.

Referenced by SCIP_DECL_PRICERINIT().

SCIP_RETCODE SCIPprobdataPrintGraph ( SCIP *  scip,
const char *  filename,
SCIP_SOL *  sol,
SCIP_Bool  printsol 
)

print (undirected) graph in GML format

Parameters
scipSCIP data structure
filenamename of the output file
solsolution to be printed; or NULL for LP solution
printsolshould solution be printed?

Definition at line 2526 of file probdata_stp.c.

References SCIP_ProbData::edgevars, FALSE, probdataPrintGraph(), and TRUE.

Referenced by pricing().

SCIP_RETCODE SCIPprobdataPrintGraph2 ( const GRAPH graph,
const char *  filename,
SCIP_Bool *  edgemark 
)

print graph (in undirected form) in GML format with given edges highlighted

Parameters
graphGraph to be printed
filenameName of the output file
edgemarkArray of (undirected) edges to highlight

Definition at line 3208 of file probdata_stp.c.

References GRAPH::cost, EAT_FREE, GRAPH::edges, FALSE, GRAPH::head, GRAPH::knots, GRAPH::mark, GRAPH::oeat, GRAPH::source, GRAPH::tail, GRAPH::term, and TRUE.

Referenced by SCIPheurImproveSteinerTree(), and sd_red().

void SCIPprobdataSetDualBound ( SCIP *  scip,
SCIP_Real  dual 
)

writes end of log file

Parameters
scipSCIP data structure
dualdual bound

Definition at line 3363 of file probdata_stp.c.

References TRUE.

void SCIPprobdataSetGraph ( SCIP_PROBDATA *  probdata,
GRAPH graph 
)

sets the probdata graph

Parameters
probdataproblem data
graphgraph data structure

Definition at line 2246 of file probdata_stp.c.

References SCIP_ProbData::graph.

void SCIPprobdataSetNSolvers ( SCIP *  scip,
int  nSolvers 
)

writes end of log file

Parameters
scipSCIP data structure
nSolversthe number of solvers

Definition at line 3378 of file probdata_stp.c.

References SCIP_ProbData::nSolvers.

void SCIPprobdataSetOffset ( SCIP_PROBDATA *  probdata,
SCIP_Real  offset 
)

sets the offset

Parameters
probdataproblem data
offsetthe offset value

Definition at line 2269 of file probdata_stp.c.

References SCIP_ProbData::offset.

SCIP_RETCODE SCIPprobdataWriteIntermediateSolution ( SCIP *  scip)

writes the best solution to the intermediate solution file

Parameters
scipSCIP data structure

Definition at line 2570 of file probdata_stp.c.

References SCIPprobdataWriteSolution().

Referenced by SCIP_DECL_EVENTEXEC().

SCIP_RETCODE SCIPprobdataWriteLogfileEnd ( SCIP *  scip)

writes end of log file

Parameters
scipSCIP data structure

Definition at line 3302 of file probdata_stp.c.

References SCIPprobdataWriteLogLine(), SCIPprobdataWriteSolution(), and STP_MAX_NODE_WEIGHT.

Referenced by SCIP_DECL_DIALOGEXEC().

void SCIPprobdataWriteLogLine ( SCIP *  scip,
const char *  formatstr,
  ... 
)

writes a line to the log file

Parameters
scipSCIP data structure
formatstrformat string like in printf() function

Definition at line 2911 of file probdata_stp.c.

Referenced by SCIP_DECL_EVENTEXEC(), SCIP_DECL_PROBEXITSOL(), SCIPprobdataCreate(), SCIPprobdataWriteLogfileEnd(), and SCIPprobdataWriteSolution().