Dear Andrew,

GCC supports the %la format specification.

I made a decimal dump, 16 digits, and I can reproduce cycling on Win32
and Linux, with different compilers.

Thanks,

Ali

Attachment: dump_dec
Description: Binary data

#include "glpk.h"

#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <string>

using namespace std;

int main() {

	ifstream in("dump_dec");

	string s;

	int to_read;

	in >> to_read;

	const int k = to_read;

	int* const ia = new int[1+k];

	int* const ja = new int[1+k];

	double* const ar = new double[1+k];

	for (int i=1; i<k; ++i) {

		in >> ia[i];

		in >> ja[i];

		in >> ar[i];
	}


	in >> to_read;

	const int n = to_read;

	glp_prob* lp = glp_create_prob();

	glp_add_rows(lp, n);

	glp_add_cols(lp, n);

	for (int i=1; i<=n; ++i) {

		double lb, ub;

		in >> lb;

		in >> ub;

		int row_type = GLP_FX;

		if (lb != ub)
			row_type = GLP_DB;

		glp_set_row_bnds(lp, i, row_type, lb, ub);
	}

	for (int j=1; j<=n; ++j) {

		glp_set_col_bnds(lp, j, GLP_DB, -1.0, 1.0);

		glp_set_obj_coef(lp, j, 0.0);
	}

	glp_load_matrix(lp, k-1, ia, ja, ar);

	glp_write_lp(lp, 0, "dump.lp");

	glp_smcp parm;

	glp_init_smcp(&parm);

	glp_scale_prob(lp, GLP_SF_AUTO);

	glp_simplex(lp, &parm);

	glp_set_obj_coef(lp, 6, 1.0);

	glp_simplex(lp, &parm);

	glp_set_obj_coef(lp, 6, 0.0);
	glp_set_obj_coef(lp, 8, 1.0);

	glp_simplex(lp, &parm);

	glp_set_obj_coef(lp, 8,  0.0);
	glp_set_obj_coef(lp, 6, -1.0);

	glp_simplex(lp, &parm);

	glp_set_obj_coef(lp, 6, 0.0);
	glp_set_obj_coef(lp, 2, 1.0);

	glp_simplex(lp, &parm);

	glp_set_obj_coef(lp, 2, 0.0);
	glp_set_obj_coef(lp, 1, 1.0);

	glp_simplex(lp, &parm);

	printf("Never gets here!\n");

	return 0;
}
_______________________________________________
Bug-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-glpk

Reply via email to