Beispiel #1
0
void print_pool_n(SS *scatter_search, int n) {
    P *pool = scatter_search->p;
    solution *sol = (solution *)NULL;

    if ((guint)n > g_list_length(pool->list)) {
        printf("n is too big\n");
    } else {
        for (int i = 0; i < n; ++i) {
            sol = ((solution *)g_list_nth(pool->list, i)->data);
            printf("solution %d with wct %d\n", i, sol->totalweightcomptime);
            solution_print(sol);
        }
    }
}
void profit_solve(graph g, vector<int>& allocation, vector<double>& pricing, bool integer) {
  int **columns = (int **)malloc(g->bidders * sizeof(int *));
  for(int i = 0; i < g->bidders; i++)
    columns[i] = (int *)calloc(g->items, sizeof(int));
  IloEnv env;
  try {
    if(getVerbosity() != CplexOutput)
      env.setOut(env.getNullStream());
    IloModel model(env);
    IloNumVarArray x(env);
    IloNumVarArray p(env);
    IloNumVarArray z(env);
    IloCplex cplex(model);
    profit_create_vars(g, model, x, p, z, columns);
    profit_create_objective(g, model, x, z, columns);
    model.add(profit_constraints(g, model, x, p, z, columns));
    config_cplex(cplex); 
    if(!integer) {
      model.add(IloConversion(env, x, ILOFLOAT));
    } else {
      profit_load(g, cplex, model, x, p, z, columns, allocation, pricing);
    }
    clock_start();
    if (!cplex.solve()) {
      failed_print(g);
    } else {
      if(integer)
        solution_print(cplex, env, g);  
      else
        relax_print(cplex, env);
    }
  }
  catch (IloException& e) {
    cerr << "Concert exception caught: " << e << endl;
  }
  catch (...) {
    cerr << "Unknown exception caught" << endl;
  }
}
Beispiel #3
0
 /*Imprime el contenido de un elemento*/
int elelist_print(FILE *f, const EleList *pele){
	if(!f || !pele || !pele->info){
		return -1;
	}
	return solution_print(f, elelist_getInfo((EleList *)pele));
}
Beispiel #4
0
void print_sol(void *data, void *user_data) {
    solution *sol = (solution *)data;
    int *i = (int *)user_data;
    printf("solution %d with wct %d \n", (*i)++, sol->totalweightcomptime);
    solution_print(sol);
}