Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

public methods for solutions

Author
Tobias Achterberg
Timo Berthold
Gerald Gamrath
Leona Gottwald
Stefan Heinz
Gregor Hendel
Thorsten Koch
Alexander Martin
Marc Pfetsch
Michael Winkler
Kati Wolter

Definition in file scip_sol.c.

#include <string.h>
#include <strings.h>
#include "blockmemshell/memory.h"
#include "scip/cons.h"
#include "scip/cons_linear.h"
#include "scip/debug.h"
#include "scip/lp.h"
#include "scip/nlp.h"
#include "scip/primal.h"
#include "scip/prob.h"
#include "scip/pub_cons.h"
#include "scip/pub_fileio.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_sol.h"
#include "scip/pub_var.h"
#include "scip/relax.h"
#include "scip/scip_cons.h"
#include "scip/scip_copy.h"
#include "scip/scip_general.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_nlp.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_sol.h"
#include "scip/scip_solve.h"
#include "scip/scip_solvingstats.h"
#include "scip/scip_var.h"
#include "scip/set.h"
#include "scip/sol.h"
#include "scip/struct_lp.h"
#include "scip/struct_mem.h"
#include "scip/struct_primal.h"
#include "scip/struct_prob.h"
#include "scip/struct_scip.h"
#include "scip/struct_set.h"
#include "scip/struct_stat.h"
#include "scip/struct_var.h"
#include "scip/tree.h"
#include "xml/xml.h"

Go to the source code of this file.

Functions

static SCIP_RETCODE checkSolOrig (SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool checkmodifiable)
 
void SCIPupdateSolIntegralityViolation (SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol)
 
void SCIPupdateSolBoundViolation (SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
 
void SCIPupdateSolLPRowViolation (SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
 
void SCIPupdateSolConsViolation (SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
 
void SCIPupdateSolLPConsViolation (SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
 
void SCIPactivateSolViolationUpdates (SCIP *scip)
 
void SCIPdeactivateSolViolationUpdates (SCIP *scip)
 
SCIP_RETCODE SCIPcreateSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateLPSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateNLPSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateRelaxSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreatePseudoSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateCurrentSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreatePartialSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateUnknownSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateOrigSol (SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
 
SCIP_RETCODE SCIPcreateSolCopy (SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
 
SCIP_RETCODE SCIPcreateSolCopyOrig (SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
 
static SCIP_RETCODE setupAndSolveFiniteSolSubscip (SCIP *scip, SCIP *subscip, SCIP_VAR **origvars, int norigvars, SCIP_Real *solvals, SCIP_Bool *success)
 
SCIP_RETCODE SCIPcreateFiniteSolCopy (SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol, SCIP_Bool *success)
 
SCIP_RETCODE SCIPfreeSol (SCIP *scip, SCIP_SOL **sol)
 
SCIP_RETCODE SCIPlinkLPSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPlinkNLPSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPlinkRelaxSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPlinkPseudoSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPlinkCurrentSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPclearSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPunlinkSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPsetSolVal (SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
 
SCIP_RETCODE SCIPsetSolVals (SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
 
SCIP_RETCODE SCIPincSolVal (SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
 
SCIP_Real SCIPgetSolVal (SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
 
SCIP_RETCODE SCIPgetSolVals (SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
 
SCIP_Real SCIPgetSolOrigObj (SCIP *scip, SCIP_SOL *sol)
 
SCIP_Real SCIPgetSolTransObj (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPrecomputeSolObj (SCIP *scip, SCIP_SOL *sol)
 
SCIP_Real SCIPtransformObj (SCIP *scip, SCIP_Real obj)
 
SCIP_Real SCIPretransformObj (SCIP *scip, SCIP_Real obj)
 
SCIP_Real SCIPgetSolTime (SCIP *scip, SCIP_SOL *sol)
 
int SCIPgetSolRunnum (SCIP *scip, SCIP_SOL *sol)
 
SCIP_Longint SCIPgetSolNodenum (SCIP *scip, SCIP_SOL *sol)
 
SCIP_HEURSCIPgetSolHeur (SCIP *scip, SCIP_SOL *sol)
 
SCIP_Bool SCIPareSolsEqual (SCIP *scip, SCIP_SOL *sol1, SCIP_SOL *sol2)
 
SCIP_RETCODE SCIPadjustImplicitSolVals (SCIP *scip, SCIP_SOL *sol, SCIP_Bool uselprows)
 
SCIP_RETCODE SCIPprintSol (SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
 
SCIP_RETCODE SCIPprintTransSol (SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
 
SCIP_RETCODE SCIPprintMIPStart (SCIP *scip, SCIP_SOL *sol, FILE *file)
 
SCIP_RETCODE SCIPgetDualSolVal (SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
 
static SCIP_RETCODE printDualSol (SCIP *scip, FILE *file, SCIP_Bool printzeros)
 
SCIP_Bool SCIPisDualSolAvailable (SCIP *scip, SCIP_Bool printreason)
 
SCIP_RETCODE SCIPprintDualSol (SCIP *scip, FILE *file, SCIP_Bool printzeros)
 
SCIP_RETCODE SCIPprintRay (SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
 
int SCIPgetNSols (SCIP *scip)
 
SCIP_SOL ** SCIPgetSols (SCIP *scip)
 
SCIP_SOLSCIPgetBestSol (SCIP *scip)
 
SCIP_RETCODE SCIPprintBestSol (SCIP *scip, FILE *file, SCIP_Bool printzeros)
 
SCIP_RETCODE SCIPprintBestTransSol (SCIP *scip, FILE *file, SCIP_Bool printzeros)
 
SCIP_RETCODE SCIProundSol (SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
 
SCIP_RETCODE SCIPretransformSol (SCIP *scip, SCIP_SOL *sol)
 
SCIP_RETCODE SCIPreadSol (SCIP *scip, const char *filename)
 
static SCIP_RETCODE readSolFile (SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
 
static SCIP_RETCODE readXmlSolFile (SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
 
SCIP_RETCODE SCIPreadSolFile (SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
 
SCIP_RETCODE SCIPaddSol (SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
 
SCIP_RETCODE SCIPaddSolFree (SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
 
SCIP_RETCODE SCIPaddCurrentSol (SCIP *scip, SCIP_HEUR *heur, SCIP_Bool *stored)
 
SCIP_RETCODE SCIPtrySol (SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
 
SCIP_RETCODE SCIPtrySolFree (SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
 
SCIP_RETCODE SCIPtryCurrentSol (SCIP *scip, SCIP_HEUR *heur, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
 
SCIP_SOL ** SCIPgetPartialSols (SCIP *scip)
 
int SCIPgetNPartialSols (SCIP *scip)
 
SCIP_RETCODE SCIPcheckSol (SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
 
SCIP_RETCODE SCIPcheckSolOrig (SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
 
SCIP_Bool SCIPhasPrimalRay (SCIP *scip)
 
SCIP_Real SCIPgetPrimalRayVal (SCIP *scip, SCIP_VAR *var)
 
SCIP_RETCODE SCIPupdatePrimalRay (SCIP *scip, SCIP_SOL *primalray)
 

Function Documentation

◆ checkSolOrig()

static SCIP_RETCODE checkSolOrig ( SCIP scip,
SCIP_SOL sol,
SCIP_Bool feasible,
SCIP_Bool  printreason,
SCIP_Bool  completely,
SCIP_Bool  checkbounds,
SCIP_Bool  checkintegrality,
SCIP_Bool  checklprows,
SCIP_Bool  checkmodifiable 
)
static

checks solution for feasibility in original problem without adding it to the solution store; to improve the performance we use the following order when checking for violations:

  1. variable bounds
  2. constraint handlers with positive or zero priority that don't need constraints (e.g. integral constraint handler)
  3. original constraints
  4. constraint handlers with negative priority that don't need constraints (e.g. Benders' decomposition constraint handler)
Parameters
scipSCIP data structure
solprimal CIP solution
feasiblestores whether given solution is feasible
printreasonShould the reason for the violation be printed?
completelyShould all violations be checked if printreason is true?
checkboundsShould the bounds of the variables be checked?
checkintegralityHas integrality to be checked?
checklprowsDo constraints represented by rows in the current LP have to be checked?
checkmodifiablehave modifiable constraint to be checked?

Definition at line 101 of file scip_sol.c.

References SCIP_Set::conshdlrs, SCIP_Prob::conss, FALSE, h, Scip::mem, Scip::messagehdlr, SCIP_Set::nconshdlrs, SCIP_Prob::nconss, NULL, SCIP_Prob::nvars, Scip::origprob, SCIP_Mem::probmem, SCIP_CALL, SCIP_FEASIBLE, SCIP_OKAY, SCIP_Real, SCIPcheckStage(), SCIPconsCheck(), SCIPconshdlrCheck(), SCIPconshdlrGetCheckPriority(), SCIPconshdlrNeedsCons(), SCIPconsIsChecked(), SCIPconsIsModifiable(), SCIPmessagePrintInfo(), SCIPrelDiff(), SCIPsetIsFeasGT(), SCIPsetIsFeasLT(), SCIPsolGetVal(), SCIPsolResetViolations(), SCIPupdateSolBoundViolation(), SCIPvarGetLbOriginal(), SCIPvarGetName(), SCIPvarGetUbOriginal(), Scip::set, Scip::stat, TRUE, and SCIP_Prob::vars.

Referenced by SCIPcheckSol(), SCIPcheckSolOrig(), SCIPtryCurrentSol(), SCIPtrySol(), and SCIPtrySolFree().

◆ setupAndSolveFiniteSolSubscip()

static SCIP_RETCODE setupAndSolveFiniteSolSubscip ( SCIP scip,
SCIP subscip,
SCIP_VAR **  origvars,
int  norigvars,
SCIP_Real solvals,
SCIP_Bool success 
)
static

helper method that sets up and solves the sub-SCIP for removing infinite values from solutions

Parameters
scipSCIP data structure
subscipSCIP data structure of sub-SCIP
origvarsoriginal problem variables of main SCIP
norigvarsnumber of original problem variables of main SCIP
solvalsarray with solution values of variables; infinite ones are replaced
successpointer to store if removing infinite values was successful

Definition at line 698 of file scip_sol.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIP_VERBLEVEL_NONE, SCIPaddCoefLinear(), SCIPaddCons(), SCIPaddVar(), SCIPblkmem(), SCIPchgVarObj(), SCIPchgVarType(), SCIPcopyOrig(), SCIPcreateConsBasicLinear(), SCIPcreateVar(), SCIPfixVar(), SCIPgetBestSol(), SCIPgetSolVal(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPinfinity(), SCIPisFeasGT(), SCIPisFeasLT(), SCIPisInfinity(), SCIPreleaseCons(), SCIPreleaseVar(), SCIPsetIntParam(), SCIPsnprintf(), SCIPsolve(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetUbLocal(), and TRUE.

Referenced by SCIPcreateFiniteSolCopy().

◆ printDualSol()

static SCIP_RETCODE printDualSol ( SCIP scip,
FILE *  file,
SCIP_Bool  printzeros 
)
static

outputs dual solution from LP solver to file stream

Parameters
scipSCIP data structure
fileoutput file (or NULL for standard output)
printzerosshould variables set to zero be printed?

Definition at line 2026 of file scip_sol.c.

References SCIP_Prob::conss, SCIP_Lp::dualfeasible, Scip::lp, Scip::messagehdlr, SCIP_Prob::nconss, NULL, Scip::origprob, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetName(), SCIPgetDualSolVal(), SCIPisInfinity(), SCIPisZero(), SCIPmessageFPrintInfo(), and SCIP_Lp::solved.

Referenced by SCIPprintDualSol().

◆ readSolFile()

static SCIP_RETCODE readSolFile ( SCIP scip,
const char *  filename,
SCIP_SOL sol,
SCIP_Bool partial,
SCIP_Bool error 
)
static

reads a given solution file and store the solution values in the given solution pointer

Parameters
scipSCIP data structure
filenamename of the input file
solsolution pointer
partialpointer to store if the solution is partial (or NULL, if not needed)
errorpointer store if an error occured

Definition at line 2564 of file scip_sol.c.

References FALSE, TimInput::lineno, NULL, SCIP_Prob::nvars, Scip::origprob, SCIP_Bool, SCIP_CALL, SCIP_CALL_FINALLY, SCIP_INVALIDDATA, SCIP_MAXSTRLEN, SCIP_NOFILE, SCIP_OKAY, SCIP_Real, SCIP_STAGE_PROBLEM, SCIP_UNKNOWN, SCIP_VARSTATUS_FIXED, SCIP_VARSTATUS_MULTAGGR, SCIP_VERBLEVEL_NORMAL, SCIPerrorMessage, SCIPfclose(), SCIPfeof(), SCIPfgets(), SCIPfindVar(), SCIPfopen(), SCIPgetStage(), SCIPinfinity(), SCIPisTransformed(), SCIPprintSysError(), SCIPsetSolVal(), SCIPsnprintf(), SCIPsolIsPartial(), SCIPsolMarkPartial(), SCIPvarGetName(), SCIPvarGetProbvar(), SCIPvarGetStatus(), SCIPverbMessage(), Scip::set, Scip::stat, TRUE, and SCIP_Prob::vars.

Referenced by SCIPreadSolFile().

◆ readXmlSolFile()

static SCIP_RETCODE readXmlSolFile ( SCIP scip,
const char *  filename,
SCIP_SOL sol,
SCIP_Bool partial,
SCIP_Bool error 
)
static

reads a given xml solution file and store the solution values in the given solution pointer

Parameters
scipSCIP data structure
filenamename of the input file
solsolution pointer
partialpointer to store if the solution is partial (or NULL if not needed)
errorpointer store if an error occured

Definition at line 2721 of file scip_sol.c.

References FALSE, NULL, SCIP_Prob::nvars, Scip::origprob, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_READERROR, SCIP_Real, SCIP_STAGE_PROBLEM, SCIP_UNKNOWN, SCIP_VARSTATUS_FIXED, SCIP_VARSTATUS_MULTAGGR, SCIP_VERBLEVEL_NORMAL, SCIPerrorMessage, SCIPfindVar(), SCIPgetStage(), SCIPinfinity(), SCIPisTransformed(), SCIPsetSolVal(), SCIPsolIsPartial(), SCIPsolMarkPartial(), SCIPvarGetName(), SCIPvarGetProbvar(), SCIPvarGetStatus(), SCIPverbMessage(), SCIPwarningMessage(), Scip::set, Scip::stat, TRUE, SCIP_Prob::vars, xmlFindNodeMaxdepth(), xmlFirstChild(), xmlFreeNode(), xmlGetAttrval(), xmlNextSibl(), and xmlProcess().

Referenced by SCIPreadSolFile().