25 memset((
void *)ctrl, 0,
sizeof(
ctrl_t));
93 ctrl->
tpwgts =
rmalloc(nparts*ncon,
"SetupCtrl: ctrl->tpwgts");
99 for (j=0; j<
ncon; j++)
100 ctrl->
tpwgts[i*ncon+j] = 1.0/nparts;
115 for (i=0; i<ctrl->
ncon; i++)
121 ctrl->
pijbm =
rmalloc(nparts*ncon,
"SetupCtrl: ctrl->pijbm");
144 for (i=0; i<ctrl->
nparts; i++) {
145 for (j=0; j<graph->
ncon; j++)
158 for (i=0; i<2; i++) {
159 for (j=0; j<graph->
ncon; j++)
172 printf(
" Runtime parameters:\n");
174 printf(
" Objective type: ");
177 printf(
"METIS_OBJTYPE_CUT\n");
180 printf(
"METIS_OBJTYPE_VOL\n");
183 printf(
"METIS_OBJTYPE_NODE\n");
186 printf(
"Unknown!\n");
189 printf(
" Coarsening type: ");
190 switch (ctrl->
ctype) {
192 printf(
"METIS_CTYPE_RM\n");
195 printf(
"METIS_CTYPE_SHEM\n");
198 printf(
"Unknown!\n");
201 printf(
" Initial partitioning type: ");
204 printf(
"METIS_IPTYPE_GROW\n");
207 printf(
"METIS_IPTYPE_RANDOM\n");
210 printf(
"METIS_IPTYPE_EDGE\n");
213 printf(
"METIS_IPTYPE_NODE\n");
216 printf(
"METIS_IPTYPE_METISRB\n");
219 printf(
"Unknown!\n");
222 printf(
" Refinement type: ");
223 switch (ctrl->
rtype) {
225 printf(
"METIS_RTYPE_FM\n");
228 printf(
"METIS_RTYPE_GREEDY\n");
231 printf(
"METIS_RTYPE_SEP2SIDED\n");
234 printf(
"METIS_RTYPE_SEP1SIDED\n");
237 printf(
"Unknown!\n");
240 printf(
" Perform a 2-hop matching: %s\n", (ctrl->
no2hop ?
"Yes" :
"No"));
242 printf(
" Number of balancing constraints: %"PRIDX"\n", ctrl->
ncon);
243 printf(
" Number of refinement iterations: %"PRIDX"\n", ctrl->
niter);
244 printf(
" Random number seed: %"PRIDX"\n", ctrl->
seed);
247 printf(
" Number of separators: %"PRIDX"\n", ctrl->
nseps);
248 printf(
" Compress graph prior to ordering: %s\n", (ctrl->
compress ?
"Yes" :
"No"));
249 printf(
" Detect & order connected components separately: %s\n", (ctrl->
ccorder ?
"Yes" :
"No"));
250 printf(
" Prunning factor for high degree vertices: %"PRREAL"\n", ctrl->
pfactor);
253 printf(
" Number of partitions: %"PRIDX"\n", ctrl->
nparts);
254 printf(
" Number of cuts: %"PRIDX"\n", ctrl->
ncuts);
255 printf(
" User-supplied ufactor: %"PRIDX"\n", ctrl->
ufactor);
258 printf(
" Minimize connectivity: %s\n", (ctrl->
minconn ?
"Yes" :
"No"));
259 printf(
" Create contigous partitions: %s\n", (ctrl->
contig ?
"Yes" :
"No"));
262 modnum = (ctrl->
ncon==1 ? 5 : (ctrl->
ncon==2 ? 3 : (ctrl->
ncon==3 ? 2 : 1)));
263 printf(
" Target partition weights: ");
264 for (i=0; i<ctrl->
nparts; i++) {
267 printf(
"%4"PRIDX"=[", i);
268 for (j=0; j<ctrl->
ncon; j++)
269 printf(
"%s%.2e", (j==0 ?
"" :
" "), (
double)ctrl->
tpwgts[i*ctrl->
ncon+j]);
275 printf(
" Allowed maximum load imbalance: ");
276 for (i=0; i<ctrl->
ncon; i++)
304 IFSET(dbglvl,
METIS_DBG_INFO, printf(
"Input Error: Incorrect initial partitioning scheme.\n"));
311 if (ctrl->
ncuts <= 0) {
315 if (ctrl->
niter <= 0) {
331 if (ctrl->
ncon <= 0) {
336 for (i=0; i<ctrl->
ncon; i++) {
338 if (sum < 0.99 || sum > 1.01) {
340 printf(
"Input Error: Incorrect sum of %"PRREAL" for tpwgts for constraint %"PRIDX".\n", sum, i));
344 for (i=0; i<ctrl->
ncon; i++) {
345 for (j=0; j<ctrl->
nparts; j++) {
348 printf(
"Input Error: Incorrect tpwgts for partition %"PRIDX" and constraint %"PRIDX".\n", j, i));
354 for (i=0; i<ctrl->
ncon; i++) {
357 printf(
"Input Error: Incorrect ubfactor for constraint %"PRIDX".\n", i));
374 IFSET(dbglvl,
METIS_DBG_INFO, printf(
"Input Error: Incorrect initial partitioning scheme.\n"));
381 if (ctrl->
ncuts <= 0) {
385 if (ctrl->
niter <= 0) {
401 if (ctrl->
ncon <= 0) {
414 for (i=0; i<ctrl->
ncon; i++) {
416 if (sum < 0.99 || sum > 1.01) {
418 printf(
"Input Error: Incorrect sum of %"PRREAL" for tpwgts for constraint %"PRIDX".\n", sum, i));
422 for (i=0; i<ctrl->
ncon; i++) {
423 for (j=0; j<ctrl->
nparts; j++) {
426 printf(
"Input Error: Incorrect tpwgts for partition %"PRIDX" and constraint %"PRIDX".\n", j, i));
432 for (i=0; i<ctrl->
ncon; i++) {
435 printf(
"Input Error: Incorrect ubfactor for constraint %"PRIDX".\n", i));
454 IFSET(dbglvl,
METIS_DBG_INFO, printf(
"Input Error: Incorrect initial partitioning scheme.\n"));
461 if (ctrl->
nseps <= 0) {
465 if (ctrl->
niter <= 0) {
481 if (ctrl->
ncon != 1) {
498 for (i=0; i<ctrl->
ncon; i++) {
501 printf(
"Input Error: Incorrect ubfactor for constraint %"PRIDX".\n", i));
#define I2RUBFACTOR(ufactor)
ctrl_t * SetupCtrl(moptype_et optype, idx_t *options, idx_t ncon, idx_t nparts, real_t *tpwgts, real_t *ubvec)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t * nparts
void gk_errexit(int signum, char *f_str,...)
void SetupKWayBalMultipliers(ctrl_t *ctrl, graph_t *graph)
NonlinearFactorGraph graph
int CheckParams(ctrl_t *ctrl)
#define OMETIS_DEFAULT_UFACTOR
void Setup2WayBalMultipliers(ctrl_t *ctrl, graph_t *graph, real_t *tpwgts)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t * ubvec
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t * tpwgts
void PrintCtrl(ctrl_t *ctrl)
void * gk_malloc(size_t nbytes, char *msg)
void gk_free(void **ptr1,...)
void FreeCtrl(ctrl_t **r_ctrl)
#define PMETIS_DEFAULT_UFACTOR
#define IFSET(a, flag, cmd)
#define MCPMETIS_DEFAULT_UFACTOR
#define GETOPTION(options, idx, defval)
#define KMETIS_DEFAULT_UFACTOR