Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v9-minor'
Browse files Browse the repository at this point in the history
  • Loading branch information
scip-ci committed Dec 15, 2024
2 parents 6177171 + 752f985 commit 17dd762
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/scip/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,9 +807,9 @@ SCIP_RETCODE SCIPbranchcandGetPseudoCands(

/* pseudo branching candidates are non-fixed binary, integer, and implicit integer variables */
npcs = 0;
for( v = 0; v < prob->nbinvars + prob->nintvars + prob->nimplvars; ++v )
for( v = 0; v < SCIPprobGetNBinVars(prob) + SCIPprobGetNIntVars(prob) + SCIPprobGetNImplVars(prob); ++v )
{
var = prob->vars[v];
var = SCIPprobGetVars(prob)[v];
assert(var != NULL);
assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_LOOSE || SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN);
assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY
Expand Down
8 changes: 4 additions & 4 deletions src/scip/pricer.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ SCIP_RETCODE SCIPpricerRedcost(

SCIPsetDebugMsg(set, "executing reduced cost pricing of variable pricer <%s>\n", pricer->name);

oldnvars = prob->nvars;
oldnvars = SCIPprobGetNVars(prob);

/* start timing */
SCIPclockStart(pricer->pricerclock, set);
Expand All @@ -426,7 +426,7 @@ SCIP_RETCODE SCIPpricerRedcost(

/* evaluate result */
pricer->ncalls++;
pricer->nvarsfound += prob->nvars - oldnvars;
pricer->nvarsfound += SCIPprobGetNVars(prob) - oldnvars;

return SCIP_OKAY;
}
Expand All @@ -452,7 +452,7 @@ SCIP_RETCODE SCIPpricerFarkas(

SCIPsetDebugMsg(set, "executing Farkas pricing of variable pricer <%s>\n", pricer->name);

oldnvars = prob->nvars;
oldnvars = SCIPprobGetNVars(prob);

/* start timing */
SCIPclockStart(pricer->pricerclock, set);
Expand All @@ -465,7 +465,7 @@ SCIP_RETCODE SCIPpricerFarkas(

/* evaluate result */
pricer->ncalls++;
pricer->nvarsfound += prob->nvars - oldnvars;
pricer->nvarsfound += SCIPprobGetNVars(prob) - oldnvars;

return SCIP_OKAY;
}
Expand Down
10 changes: 5 additions & 5 deletions src/scip/primal.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ SCIP_RETCODE primalAddSol(
/* make sure that the primal bound is at least the lower bound */
if( ! SCIPsetIsInfinity(set, obj) && ! SCIPsetIsInfinity(set, -SCIPgetLowerbound(set->scip)) && SCIPsetIsFeasGT(set, SCIPgetLowerbound(set->scip), obj) )
{
if( origprob->objsense == SCIP_OBJSENSE_MINIMIZE )
if( SCIPprobGetObjsense(origprob) == SCIP_OBJSENSE_MINIMIZE )
{
SCIPmessagePrintWarning(messagehdlr, "Dual bound %g is larger than the objective of the primal solution %g. The solution might not be optimal.\n",
SCIPprobExternObjval(transprob, origprob, set, SCIPgetLowerbound(set->scip)), SCIPprobExternObjval(transprob, origprob, set, obj));
Expand Down Expand Up @@ -1834,10 +1834,10 @@ SCIP_RETCODE SCIPprimalTransformSol(
assert(solvalssize == 0 || solvals != NULL);
assert(solvalssize == 0 || solvalset != NULL);

origvars = origprob->vars;
norigvars = origprob->nvars;
transvars = transprob->vars;
ntransvars = transprob->nvars;
origvars = SCIPprobGetVars(origprob);
norigvars = SCIPprobGetNVars(origprob);
transvars = SCIPprobGetVars(transprob);
ntransvars = SCIPprobGetNVars(transprob);
assert(solvalssize == 0 || solvalssize >= ntransvars);

SCIPsetDebugMsg(set, "try to transfer original solution %p with objective %g into the transformed problem space\n",
Expand Down
73 changes: 72 additions & 1 deletion src/scip/prob.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,9 +2298,17 @@ void SCIPprobPrintStatistics(
#undef SCIPprobGetNIntVars
#undef SCIPprobGetNImplVars
#undef SCIPprobGetNContVars
#undef SCIPprobGetNConss
#undef SCIPprobGetVars
#undef SCIPprobGetNFixedVars
#undef SCIPprobGetFixedVars
#undef SCIPprobGetStartNVars
#undef SCIPprobGetNConss
#undef SCIPprobGetConss
#undef SCIPprobGetMaxNConss
#undef SCIPprobGetStartNConss
#undef SCIPprobGetObjsense
#undef SCIPprobGetObjoffset
#undef SCIPprobGetObjscale
#undef SCIPisConsCompressedEnabled
#undef SCIPprobEnableConsCompression

Expand Down Expand Up @@ -2443,6 +2451,33 @@ SCIP_VAR** SCIPprobGetVars(
return prob->vars;
}

/** gets number of fixed variables */
int SCIPprobGetNFixedVars(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->nfixedvars;
}

/** gets fixed variables */
SCIP_VAR** SCIPprobGetFixedVars(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->fixedvars;
}

/** gets number of variables existing when problem solving started */
int SCIPprobGetStartNVars(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->startnvars;
}

/** gets number of problem constraints */
int SCIPprobGetNConss(
SCIP_PROB* prob /**< problem data */
Expand All @@ -2452,6 +2487,42 @@ int SCIPprobGetNConss(
return prob->nconss;
}

/** gets problem constraints */
SCIP_CONS** SCIPprobGetConss(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->conss;
}

/** gets maximum number of constraints existing at the same time */
int SCIPprobGetMaxNConss(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->maxnconss;
}

/** gets number of constraints existing when problem solving started */
int SCIPprobGetStartNConss(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->startnconss;
}

/** gets the objective sense*/
SCIP_OBJSENSE SCIPprobGetObjsense(
SCIP_PROB* prob /**< problem data */
)
{
assert(prob != NULL);
return prob->objsense;
}

/** gets the objective offset */
SCIP_Real SCIPprobGetObjoffset(
SCIP_PROB* prob /**< problem data */
Expand Down
45 changes: 45 additions & 0 deletions src/scip/prob.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@
#include "scip/type_cons.h"
#include "scip/type_conflictstore.h"
#include "scip/type_message.h"
#include "scip/type_misc.h"

#ifdef NDEBUG
#include "scip/struct_prob.h"
#endif

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -605,11 +608,46 @@ SCIP_VAR** SCIPprobGetVars(
SCIP_PROB* prob /**< problem data */
);

/** gets number of fixed variables */
int SCIPprobGetNFixedVars(
SCIP_PROB* prob /**< problem data */
);

/** gets fixed variables */
SCIP_VAR** SCIPprobGetFixedVars(
SCIP_PROB* prob /**< problem data */
);

/** gets number of variables existing when problem solving started */
int SCIPprobGetStartNVars(
SCIP_PROB* prob /**< problem data */
);

/** gets number of problem constraints */
int SCIPprobGetNConss(
SCIP_PROB* prob /**< problem data */
);

/** gets problem constraints */
SCIP_CONS** SCIPprobGetConss(
SCIP_PROB* prob /**< problem data */
);

/** gets maximum number of constraints existing at the same time */
int SCIPprobGetMaxNConss(
SCIP_PROB* prob /**< problem data */
);

/** gets number of constraints existing when problem solving started */
int SCIPprobGetStartNConss(
SCIP_PROB* prob /**< problem data */
);

/** gets the objective sense */
SCIP_OBJSENSE SCIPprobGetObjsense(
SCIP_PROB* prob /**< problem data */
);

/** gets the objective offset */
SCIP_Real SCIPprobGetObjoffset(
SCIP_PROB* prob /**< problem data */
Expand Down Expand Up @@ -652,7 +690,14 @@ void SCIPprobEnableConsCompression(
#define SCIPprobGetNImplVars(prob) ((prob)->nimplvars)
#define SCIPprobGetNContVars(prob) ((prob)->ncontvars)
#define SCIPprobGetVars(prob) ((prob)->vars)
#define SCIPprobGetNFixedVars(prob) ((prob)->nfixedvars)
#define SCIPprobGetFixedVars(prob) ((prob)->fixedvars)
#define SCIPprobGetStartNVars(prob) ((prob)->startnvars)
#define SCIPprobGetNConss(prob) ((prob)->nconss)
#define SCIPprobGetConss(prob) ((prob)->conss)
#define SCIPprobGetMaxNConss(prob) ((prob)->maxnconss)
#define SCIPprobGetStartNConss(prob) ((prob)->startnconss)
#define SCIPprobGetObjsense(prob) ((prob)->objsense)
#define SCIPprobGetObjoffset(prob) ((prob)->objoffset)
#define SCIPprobGetObjscale(prob) ((prob)->objscale)
#define SCIPprobIsConsCompressionEnabled(prob) ((prob)->conscompression)
Expand Down
30 changes: 15 additions & 15 deletions src/scip/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ SCIP_RETCODE SCIPreaderWrite(
int nvars;
int i;

vars = prob->vars;
nvars = prob->nvars;
fixedvars = prob->fixedvars;
nfixedvars = prob->nfixedvars;
vars = SCIPprobGetVars(prob);
nvars = SCIPprobGetNVars(prob);
fixedvars = SCIPprobGetFixedVars(prob);
nfixedvars = SCIPprobGetNFixedVars(prob);

/* case of the transformed problem, we want to write currently valid problem */
if( prob->transformed )
if( SCIPprobIsTransformed(prob) )
{
SCIP_CONSHDLR** conshdlrs;
int nconshdlrs;
Expand Down Expand Up @@ -365,8 +365,8 @@ SCIP_RETCODE SCIPreaderWrite(
}
else
{
conss = prob->conss;
nconss = prob->nconss;
conss = SCIPprobGetConss(prob);
nconss = SCIPprobGetNConss(prob);
}

if( genericnames )
Expand Down Expand Up @@ -426,16 +426,16 @@ SCIP_RETCODE SCIPreaderWrite(
}

/* adapt objective scale for transformed problem (for the original no change is necessary) */
objscale = prob->objscale;
if( prob->transformed && prob->objsense == SCIP_OBJSENSE_MAXIMIZE )
objscale = SCIPprobGetObjscale(prob);
if( SCIPprobIsTransformed(prob) && SCIPprobGetObjsense(prob) == SCIP_OBJSENSE_MAXIMIZE )
objscale *= -1.0;

/* call reader to write problem */
retcode = reader->readerwrite(set->scip, reader, file, prob->name, prob->probdata, prob->transformed,
prob->objsense, objscale, prob->objoffset,
vars, nvars, prob->nbinvars, prob->nintvars, prob->nimplvars, prob->ncontvars,
fixedvars, nfixedvars, prob->startnvars,
conss, nconss, prob->maxnconss, prob->startnconss, genericnames, result);
retcode = reader->readerwrite(set->scip, reader, file, SCIPprobGetName(prob), SCIPprobGetData(prob), SCIPprobIsTransformed(prob),
SCIPprobGetObjsense(prob), objscale, SCIPprobGetObjoffset(prob),
vars, nvars, SCIPprobGetNBinVars(prob), SCIPprobGetNIntVars(prob), SCIPprobGetNImplVars(prob), SCIPprobGetNContVars(prob),
fixedvars, nfixedvars, SCIPprobGetStartNVars(prob),
conss, nconss, SCIPprobGetMaxNConss(prob), SCIPprobGetStartNConss(prob), genericnames, result);

/* reset variable and constraint names to original names */
if( genericnames )
Expand Down Expand Up @@ -467,7 +467,7 @@ SCIP_RETCODE SCIPreaderWrite(
SCIPsetFreeBufferArray(set, &varnames);
}

if( prob->transformed )
if( SCIPprobIsTransformed(prob) )
{
/* free memory */
SCIPsetFreeBufferArray(set, &conss);
Expand Down
2 changes: 1 addition & 1 deletion src/scip/reader_mps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ SCIP_RETCODE readQCMatrix(
}
else
{
SCIPwarningMessage(scip, "QCMATRIX section has no entries.\n");
SCIPwarningMessage(scip, "QCMATRIX section for constraint <%s> has no entries.\n", SCIPconsGetName(lincons));
}

TERMINATE:
Expand Down
4 changes: 2 additions & 2 deletions src/scip/reopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8194,8 +8194,8 @@ SCIP_RETCODE SCIPreoptSaveActiveConss(
assert(reopt->nactiveconss == 0);
assert(reopt->nmaxactiveconss == 0);

conss = transprob->conss;
nconss = transprob->nconss;
conss = SCIPprobGetConss(transprob);
nconss = SCIPprobGetNConss(transprob);

SCIPsetDebugMsg(set, "save %d active conss\n", nconss);

Expand Down
12 changes: 6 additions & 6 deletions src/scip/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3891,9 +3891,9 @@ SCIP_RETCODE focusnodeCleanupVars(
}

/* mark variables as deleted */
for( i = 0; i < transprob->nvars; i++ )
for( i = 0; i < SCIPprobGetNVars(transprob); i++ )
{
var = transprob->vars[i];
var = SCIPprobGetVars(transprob)[i];
assert(var != NULL);

/* check whether variable is deletable */
Expand Down Expand Up @@ -7115,8 +7115,8 @@ SCIP_RETCODE SCIPtreeStoreRelaxSol(
assert(transprob != NULL);
assert(SCIPrelaxationIsSolValid(relaxation));

nvars = transprob->nvars;
vars = transprob->vars;
nvars = SCIPprobGetNVars(transprob);
vars = SCIPprobGetVars(transprob);

/* check if memory still needs to be allocated or resized */
if( tree->probdiverelaxsol == NULL )
Expand Down Expand Up @@ -7158,8 +7158,8 @@ SCIP_RETCODE SCIPtreeRestoreRelaxSol(
assert(tree->probdiverelaxstored);
assert(tree->probdiverelaxsol != NULL);

nvars = transprob->nvars;
vars = transprob->vars;
nvars = SCIPprobGetNVars(transprob);
vars = SCIPprobGetVars(transprob);
assert( nvars <= tree->nprobdiverelaxsol );

/* iterate over all variables to restore the relaxation solution */
Expand Down

0 comments on commit 17dd762

Please sign in to comment.