コード例 #1
0
ファイル: rawlp.c プロジェクト: jonls/qsopt-ex
int EGLPNUM_TYPENAME_ILLraw_add_col (
	EGLPNUM_TYPENAME_rawlpdata * lp,
	const char *name,
	int intmarker)
{
	int rval = 0;
	int pindex, hit;

	rval = ILLsymboltab_register (&lp->coltab, name, -1, &pindex, &hit);
	rval = rval || hit;
	ILL_CLEANUP_IF (rval);
	if (lp->ncols >= lp->colsize)
	{
		lp->colsize *= 1.3;
		lp->colsize += 1000;
		if (lp->colsize < lp->ncols + 1)
			lp->colsize = lp->ncols + 1;
		lp->cols = EGrealloc (lp->cols, lp->colsize * sizeof (EGLPNUM_TYPENAME_colptr *));
		//rval = rval || ILLutil_reallocrus_scale (&lp->cols,
		//                                         &lp->colsize, lp->ncols + 1, 1.3,
		//                                         sizeof (EGLPNUM_TYPENAME_colptr *));
	}
	if (lp->ncols >= lp->intsize)
	{
		lp->intsize *= 1.3;
		lp->intsize += 1000;
		if (lp->intsize < lp->ncols + 1)
			lp->intsize = lp->ncols + 1;
		lp->intmarker = EGrealloc (lp->intmarker, lp->intsize * sizeof (char));
		//rval = rval || ILLutil_reallocrus_scale ((void **) &lp->intmarker,
		//                                         &lp->intsize, lp->ncols + 1,
		//                                         1.3, sizeof (char));
	}
	if (lp->ncols >= lp->is_sos_size)
	{
		lp->is_sos_size *= 1.3;
		lp->is_sos_size += 1000;
		if (lp->is_sos_size < lp->ncols + 1)
			lp->is_sos_size = lp->ncols + 1;
		lp->is_sos_member = EGrealloc (lp->is_sos_member,
																	 sizeof (int) * lp->is_sos_size);
		//rval = rval || ILLutil_reallocrus_scale ((void **) &lp->is_sos_member,
		//                                         &lp->is_sos_size, lp->ncols + 1,
		//                                         1.3, sizeof (int));
	}
	ILL_CLEANUP_IF (rval);
	lp->cols[lp->ncols] = 0;
	lp->is_sos_member[lp->ncols] = -1;
	lp->intmarker[lp->ncols] = intmarker;
	lp->ncols++;
CLEANUP:
	ILL_RETURN (rval, "EGLPNUM_TYPENAME_ILLraw_add_col");
}
コード例 #2
0
ファイル: rawlp.c プロジェクト: jonls/qsopt-ex
int EGLPNUM_TYPENAME_ILLraw_add_sos_member (
	EGLPNUM_TYPENAME_rawlpdata * lp,
	int colind)
{
	int rval = 0;

	ILL_FAILfalse (lp->nsos > 0, "we should have called EGLPNUM_TYPENAME_ILLraw_add_sos earlier");
	ILL_FAILtrue (EGLPNUM_TYPENAME_ILLraw_is_mem_other_sos (lp, colind),
								"colind is member of another sos set");

	if (lp->is_sos_member[colind] == -1)
	{
		if (lp->nsos_member >= lp->sos_weight_size)
		{
			lp->sos_weight_size *= 1.3;
			lp->sos_weight_size += 1000;
			if (lp->sos_weight_size < lp->nsos_member + 1)
				lp->sos_weight_size = lp->nsos_member + 1;
			lp->sos_weight = EGrealloc (lp->sos_weight,
																	lp->sos_weight_size * sizeof (double));
			//if (ILLutil_reallocrus_scale ((void **) &lp->sos_weight,
			//                              &lp->sos_weight_size,
			//                              lp->nsos_member + 1, 1.3, sizeof (double)))
			//{
			//  ILL_CLEANUP_IF (rval);
			//}
		}
		if (lp->nsos_member >= lp->sos_col_size)
		{
			lp->sos_col_size *= 1.3;
			lp->sos_col_size += 1000;
			if (lp->sos_col_size < lp->nsos_member + 1)
				lp->sos_col_size = lp->nsos_member + 1;
			lp->sos_col = EGrealloc (lp->sos_col, sizeof (int) * lp->sos_col_size);
			//if (ILLutil_reallocrus_scale ((void **) &lp->sos_col,
			//                              &lp->sos_col_size,
			//                              lp->nsos_member + 1, 1.3, sizeof (int)))
			//{
			//  ILL_CLEANUP_IF (rval);
			//}
		}
		lp->sos_col[lp->nsos_member] = colind;
		lp->sos_set[lp->nsos - 1].nelem++;
		lp->is_sos_member[colind] = lp->nsos - 1;
		lp->nsos_member++;
	}
CLEANUP:
	ILL_RETURN (rval, "EGLPNUM_TYPENAME_ILLraw_add_sos_member");
}
コード例 #3
0
ファイル: mpq_read_mps.c プロジェクト: rossetd0/QSopt_ex
int mpq_ILLmps_next_bound (mpq_ILLread_mps_state * state,
      mpq_t * coef)
{
    int len = 0, sign = 1;
    char c, *p;

    if (!mpq_mps_skip_comment (state)) {
	c = *state->p;
	if (c == '-') {
	    sign = -1;
	    len = 1;
	} else {
	    if (c == '+') {
		len = 1;
	    }
	}
	if (!strncasecmp (state->p + len, "INFINITY", (size_t) 8)) {
	    len += 8;
	} else {
	    if (!strncasecmp (state->p + len, "INF", (size_t) 3)) {
		len += 3;
	    }
	}
	if (len > 1) {
	    state->p += len;
	    p = state->p;
	    mpq_mps_skip_comment (state);
	    if (!mpq_END_LINE (state->p) && p == state->p) {
		/* found no blanks so this INF/INFINITY is the prefix of
		   something else */
		state->p -= len;
		return 1;	/* no coef found */
	    } else {
		if (sign == 1)
		    mpq_EGlpNumCopy (*coef, mpq_ILL_MAXDOUBLE);
		else
		    mpq_EGlpNumCopy (*coef, mpq_ILL_MINDOUBLE);
		state->field_num++;
		ILL_RESULT (0, "mpq_ILLmps_next_bound");
	    }
	}
	if (mpq_get_double (state, 0, coef)) {
	    ILL_RESULT (0, "mpq_ILLmps_next_bound");
	} else {
	    ILL_RESULT (1, "mpq_ILLmps_next_bound");	/* no coef found */
	}
    }
    ILL_RETURN (1, "mpq_ILLmps_next_bound");
}
コード例 #4
0
ファイル: rawlp.c プロジェクト: jonls/qsopt-ex
int EGLPNUM_TYPENAME_ILLraw_add_row (
	EGLPNUM_TYPENAME_rawlpdata * lp,
	const char *name,
	int sense,
	const EGLPNUM_TYPE rhs)
{
	int pindex, hit, rval = 0;

	rval = ILLsymboltab_register (&lp->rowtab, name, -1, &pindex, &hit);
	rval = rval || hit;
	ILL_CLEANUP_IF (rval);
	if (lp->nrows >= lp->sensesize)
	{
		lp->sensesize *= 1.3;
		lp->sensesize += 1000;
		if (lp->sensesize < lp->nrows + 1)
			lp->sensesize = lp->nrows + 1;
		lp->rowsense = EGrealloc (lp->rowsense, sizeof (char) * lp->sensesize);
		//if (ILLutil_reallocrus_scale ((void **) &lp->rowsense,
		//                              &lp->sensesize, lp->nrows + 1,
		//                              1.3, sizeof (char)))
		//{
		//  ILL_CLEANUP_IF (rval);
		//}
	}
	if (lp->nrows >= lp->rhssize)
	{
		if (lp->rhssize + 1000 < (lp->nrows + 1) * 1.3)
			lp->rhssize = (lp->nrows + 1) * 1.3;
		else
			lp->rhssize += 1000;
		EGLPNUM_TYPENAME_EGlpNumReallocArray (&(lp->rhs), lp->rhssize);
	}
	lp->rowsense[lp->nrows] = sense;
	EGLPNUM_TYPENAME_EGlpNumCopy (lp->rhs[lp->nrows], rhs);
	lp->nrows++;

CLEANUP:
	ILL_RETURN (rval, "EGLPNUM_TYPENAME_ILLraw_add_row");
}
コード例 #5
0
ファイル: rawlp.c プロジェクト: jonls/qsopt-ex
int EGLPNUM_TYPENAME_ILLraw_add_sos (
	EGLPNUM_TYPENAME_rawlpdata * lp,
	int tp)
{
	int rval = 0;
	EGLPNUM_TYPENAME_sosptr *sos, *bef;

	if (lp->nsos >= lp->sos_setsize)
	{
		lp->sos_setsize *= 1.3;
		lp->sos_setsize += 1000;
		if (lp->sos_setsize < lp->nsos + 1)
			lp->sos_setsize = lp->nsos + 1;
		lp->sos_set = EGrealloc (lp->sos_set, sizeof (EGLPNUM_TYPENAME_sosptr *) * lp->sos_setsize);
		//if (ILLutil_reallocrus_scale ((void **) &lp->sos_set,
		//                              &lp->sos_setsize, lp->nsos + 1, 1.3,
		//                              sizeof (EGLPNUM_TYPENAME_sosptr *)))
		//{
		//  ILL_CLEANUP_IF (rval);
		//}
	}
	sos = lp->sos_set + lp->nsos;
	sos->nelem = 0;
	sos->type = tp;
	if (lp->nsos == 0)
	{
		sos->first = 0;
	}
	else
	{
		bef = &(lp->sos_set[lp->nsos - 1]);
		sos->first = bef->first + bef->nelem;
	}
	lp->nsos++;
//CLEANUP:
	ILL_RETURN (rval, "EGLPNUM_TYPENAME_ILLraw_add_sos");
}