int main(int argc, char *argv[]) { // debug_new::PrintTrace PrintingOn; // merely activates logging of new/delete //print arguments std::cout << "Argument list with "<<argc<<" arguments\n"; for (int i=0; i<argc; i++) { std::cout << argv[i] <<"\n"; } //first argument is the filename of this program containing the current working directory //second argument is *.mod filename which needs to be opened at startup //testmatrix(); QApplication a( argc, argv ); //a.QApplication::setGraphicsSystem("raster"); //important to fix a bug in QT with scaling of pen sizes //QTranslator tor( 0 ); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. //tor.load( QString("eelsmodel.") + QTextCodec::locale(), "." ); // a.installTranslator( &tor ); /* uncomment the following line, if you want a Windows 95 look*/ //a.setStyle(QApplication::WindowsStyle); //create menu, toolbar and init the workspace MenuEelsmodel* mymainwindow=new MenuEelsmodel(); global_menueelsmodel=mymainwindow; //store the workspace global_workspaceptr=mymainwindow->getworkspaceptr(); //init the eelsmodel class Eelsmodel* myeelsmodel=new Eelsmodel(global_workspaceptr,"version 4.1"); //and store a global pointer global_eelsmodelptr=myeelsmodel; //show the window //a.setMainWidget( mymainwindow ); mymainwindow->show(); mymainwindow->showMaximized(); //make connections between menu and eelsmodel program QObject::connect(mymainwindow, SIGNAL(file_new()),myeelsmodel, SLOT(newspectrum()) ); QObject::connect(mymainwindow, SIGNAL(model_componentmaintenance()),myeelsmodel, SLOT(componentmaintenance()) ); QObject::connect(mymainwindow, SIGNAL(model_newmodel()),myeelsmodel, SLOT(newmodel()) ); QObject::connect(mymainwindow, SIGNAL(model_detector()),myeelsmodel, SLOT(slot_model_detector()) ); QObject::connect(mymainwindow, SIGNAL(file_open_msa()),myeelsmodel, SLOT(openmsa()) ); QObject::connect(mymainwindow, SIGNAL(file_open_DM()),myeelsmodel, SLOT(openDM()) ); QObject::connect(mymainwindow, SIGNAL(model_iterativefit()),myeelsmodel, SLOT(iterativefit()) ); QObject::connect(mymainwindow, SIGNAL(edit_undoselection()),myeelsmodel, SLOT(undoselection()) ); QObject::connect(mymainwindow, SIGNAL(edit_exclude()),myeelsmodel, SLOT(exclude()) ); QObject::connect(mymainwindow, SIGNAL(edit_resetexclude()),myeelsmodel, SLOT(resetexclude()) ); QObject::connect(mymainwindow, SIGNAL(file_project_open()),myeelsmodel, SLOT(slot_open_project()) ); QObject::connect(mymainwindow, SIGNAL(file_project_save()),myeelsmodel, SLOT(slot_save_project()) ); QObject::connect(mymainwindow, SIGNAL(file_model_save()),myeelsmodel, SLOT(slot_save_model()) ); QObject::connect(mymainwindow, SIGNAL(file_report_save()),myeelsmodel, SLOT((slot_save_report())) ); QObject::connect(mymainwindow, SIGNAL(file_save_as()),myeelsmodel, SLOT(slot_save_as()) ); QObject::connect(myeelsmodel, SIGNAL(enablemodel(bool)),mymainwindow, SLOT(slot_enable_model(bool))); Hello myhello; //=new Hello(); //(void*) myhello;//supress unused warning if (argc>1) { //get a *.mod file from the arguments std::string arg1=argv[0]; //contains program directory+program name std::string arg2=argv[1]; //contains argument ideally a *.mod filename to open global_eelsmodelptr->slot_open_project_from_filename(arg2); } const int result=a.exec(); //delete the pointers we have //if (myhello!=0) delete(myhello); //the hello window is deleted by itself when pressing done //if (mymainwindow!=0) delete(mymainwindow); //if (myeelsmodel!=0) delete(myeelsmodel); return result; }
colgen_t colgen_create (cmnd_t* instp) { colgen_t colgen; int i, k; char* sense = (char*) (malloc((instp->n_commods + instp->n_arcs) * sizeof(char))); colgen.instp = instp; colgen.graph = (malloc(instp->n_commods * sizeof(simple_graph_t))); colgen.overflow = 1; colgen.n_paths = colgen.prev_alloc = colgen.current_alloc = instp->n_commods; colgen.arc_cap = (malloc((instp->n_arcs + instp->n_commods) * sizeof(double))); colgen.arc_mul = (malloc(instp->n_arcs * sizeof(double))); colgen.overflow_mul = (malloc(instp->n_commods* sizeof(double))); colgen.commod_mul = (malloc(instp->n_commods * sizeof(double))); colgen.col_val = (malloc((2 + instp->n_arcs) * sizeof(double))); colgen.col_ind = (malloc((2 + instp->n_arcs) * sizeof(int))); colgen.path_ucost = (malloc(instp->n_commods * sizeof(double))); colgen.path_flow = (malloc(instp->n_commods * sizeof(double))); colgen.path_commod = (malloc(instp->n_commods * sizeof(int))); colgen.arc_total_flow = (malloc(instp->n_arcs * sizeof(double))); colgen.arc_total_ucost = (malloc(instp->n_arcs * sizeof(double))); colgen.arc_open = (malloc(instp->n_arcs * sizeof(int))); colgen.best_arc_open = (malloc(instp->n_arcs * sizeof(int))); colgen.commod_arc_flow = (malloc(instp->n_commods * sizeof(double*))); colgen.path_arcs = (malloc(colgen.current_alloc * sizeof(char*))); colgen.commod_arc_lfactor = (malloc(instp->n_commods * sizeof(double*))); for (i = 0; i < instp->n_arcs; i++) { sense[i] = GRB_LESS_EQUAL; // sense of capacity constraints colgen.arc_cap[i] = instp->arc_capacity[i]; // initial right-hand sides of capacity constraints colgen.col_val[i] = 1.0; } colgen.col_val[instp->n_arcs] = 1.0; for (k = 0; k < instp->n_commods; k++) { colgen.commod_arc_lfactor[k] = (malloc(instp->n_arcs * sizeof(double))); for (i = 0; i < instp->n_arcs; i++) colgen.commod_arc_lfactor[k][i] = 0.0; // default linearization factors colgen.path_arcs[k] = (calloc(instp->n_arcs, sizeof(char))); sense[instp->n_arcs + k] = GRB_EQUAL; // sense of bundle constraints colgen.arc_cap[instp->n_arcs + k] = instp->commod_supply[k]; // right-hand sides of bundle constraints colgen.graph[k] = simple_graph_create(instp); // pricing graph creation colgen.commod_arc_flow[k] = (malloc(instp->n_arcs * sizeof(double))); } // master problem creation GRB(newmodel(env, &colgen.lp, "CMNF path-based formulation", 0, NULL, NULL, NULL, NULL, NULL)); // the first n_arcs constraints are the capacity constraints GRB(addconstrs(colgen.lp, instp->n_arcs, 0, NULL, NULL, NULL, sense, colgen.arc_cap, NULL)); // followed by n_commods bundle constraints GRB(addconstrs(colgen.lp, instp->n_commods, 0, NULL, NULL, NULL, &sense[instp->n_arcs], instp->commod_supply, NULL)); GRB(updatemodel(colgen.lp)); // overflow paths creation (paths containing only the artificial arc from source to sink for each commodity) for (k = 0; k < instp->n_commods; k++) { colgen.path_ucost[k] = instp->commod_overflow_ucost[k]; colgen.path_flow[k] = 0.0; colgen.path_commod[k] = k; colgen.col_ind[0] = instp->n_arcs + k; GRB(addvar(colgen.lp, 1, colgen.col_ind, colgen.col_val, colgen.path_ucost[k], 0.0, instp->commod_supply[k], GRB_CONTINUOUS, NULL)); } GRB(updatemodel(colgen.lp)); // solver parameter settings GRB(setintparam(env, GRB_INT_PAR_METHOD, 1)); // optimization GRB(optimize(colgen.lp)); GRB(getintattr(colgen.lp, GRB_INT_ATTR_STATUS, &grb_status)); assert(grb_status == GRB_OPTIMAL); // initial primal and dual values GRB(getdblattrarray(colgen.lp, GRB_DBL_ATTR_X, 0, colgen.n_paths, colgen.path_flow)); GRB(getdblattrarray(colgen.lp, GRB_DBL_ATTR_PI, 0, instp->n_arcs, colgen.arc_mul)); GRB(getdblattrarray(colgen.lp, GRB_DBL_ATTR_PI, instp->n_arcs, instp->n_commods, colgen.commod_mul)); // initial bounds on the optimal objective value colgen.z_lb = 0.0; colgen.z_ub = inf; return colgen; }