Пример #1
0
int
main(int argc, char** argv) {
    OptionsCont& oc = OptionsCont::getOptions();
    // give some application descriptions
    oc.setApplicationDescription("Road network generator for the microscopic road traffic simulation SUMO.");
    oc.setApplicationName("netgen", "SUMO netgen Version " + (std::string)VERSION_STRING);
    int ret = 0;
    try {
        // initialise the application system (messaging, xml, options)
        XMLSubSys::init(false);
        fillOptions();
        OptionsIO::getOptions(true, argc, argv);
        if (oc.processMetaOptions(argc < 2)) {
            SystemFrame::close();
            return 0;
        }
        MsgHandler::initOutputOptions();
        if (!checkOptions()) {
            throw ProcessError();
        }
        RandHelper::initRandGlobal();
        NBNetBuilder nb;
        nb.applyOptions(oc);
        // build the netgen-network description
        NGNet* net = buildNetwork(nb);
        // ... and we have to do this...
        oc.resetWritable();
        // transfer to the netbuilding structures
        net->toNB();
        delete net;
        // report generated structures
        WRITE_MESSAGE(" Generation done;");
        WRITE_MESSAGE("   " + toString<int>(nb.getNodeCont().size()) + " nodes generated.");
        WRITE_MESSAGE("   " + toString<int>(nb.getEdgeCont().size()) + " edges generated.");
        nb.compute(oc);
        NWFrame::writeNetwork(oc, nb);
    } catch (ProcessError& e) {
        if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
            WRITE_ERROR(e.what());
        }
        MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
        ret = 1;
#ifndef _DEBUG
    } catch (...) {
        MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
        ret = 1;
#endif
    }
    OutputDevice::closeAll();
    SystemFrame::close();
    if (ret == 0) {
        std::cout << "Success." << std::endl;
    }
    return ret;
}
Пример #2
0
ExeErrorCode keyMdamEx::initNextKeyRange(sql_buffer_pool *pool,
			        	 atp_struct * atp0)
{
  ExeErrorCode rc = buildNetwork(pool,atp0);
  if (rc == (ExeErrorCode)0)    // if no error
    {
      current_column_ = first_column_;
      current_column_index_ = 0;
      current_column_->initNextValue();
    }
  return rc;
}
Пример #3
0
void Z3DNetworkEvaluator::setNetworkSink(Z3DCanvasRenderer *canvasRenderer)
{
  if (m_canvasRenderer == canvasRenderer)
    return;

  if (m_canvasRenderer)
    deinitializeNetwork();

  m_canvasRenderer = canvasRenderer;

  buildNetwork();
}
Пример #4
0
// Network specification stuff
void MainWindow::parseAndRouteNetwork(const QString& description)
{
    // Attempt to build the graph
    int buildResult = buildNetwork(description);
    if (buildResult < 0) {
        // Error occurred; just clear everything and abort
        clearNetwork();
        return;
    }

    // Load complete, lay it out
    if ((buildResult & WarningAbort) == 0) {
        postInfoMessage("Laying out graph...");
        applySpringLayout();
        postSuccessMessage("Graph loaded successfully!");

        // Enable the UI
        m_controlsDock->enableClearNetwork(true);
        m_controlsDock->enableGraphLayoutOptions(true);

        // Extract the start and end points
        if (buildResult == Success) {
            postInfoMessage("Beginning routing step...");
            routeNetwork();

            // Enable the graph display controls and the report generator
            m_controlsDock->enableGraphDisplayOptions(true);
            m_controlsDock->enableGenerateReport(true);
        } else {
            // Make sure the route does not exist
            m_routeStart = m_routeEnd = nullptr;
            m_route.clear();

            // Disable the UI stuff that depends on the route being generated
            m_controlsDock->enableGraphDisplayOptions(false);
            m_controlsDock->enableGenerateReport(false);

            // Inform the user
            postErrorMessage("Routing skipped step due to warnings.");
        }
    }

}
Пример #5
0
int CplexSolver::solve(CplexConverter& converter)
{
    /* Declare variables and arrays for retrieving problem data and
      solution information later on. */
    // cout << "lp solver" << endl;
    int      narcs;
    int      nnodes;
    int      solstat;
    double   objval;

    CPXENVptr env = NULL;
    CPXNETptr net = NULL;
    int       status;
    int status1;
    int       i, j;
    int cnt = 0;

    /* Initialize the CPLEX environment */

    env = CPXopenCPLEX (&status);

    /* If an error occurs, the status value indicates the reason for
      failure.  A call to CPXgeterrorstring will produce the text of
      the error message.  Note that CPXopenCPLEX produces no
      output, so the only way to see the cause of the error is to use
      CPXgeterrorstring.  For other CPLEX routines, the errors will
      be seen if the CPXPARAM_ScreenOutput indicator is set to CPX_ON.  */

    if ( env == NULL ) {
        char  errmsg[CPXMESSAGEBUFSIZE];
        fprintf (stderr, "Could not open CPLEX environment.\n");
        CPXgeterrorstring (env, status, errmsg);
        fprintf (stderr, "%s", errmsg);
        goto TERMINATE;
    }

    /* Turn on output to the screen */

    status = CPXsetintparam (env, CPX_PARAM_SCRIND, CPX_OFF);
    if ( status ) {
        fprintf (stderr,
                 "Failure to turn on screen indicator, error %d.\n", status);
        goto TERMINATE;
    }

    /* Create the problem. */

    net = CPXNETcreateprob (env, &status, "netex1");

    /* A returned pointer of NULL may mean that not enough memory
      was available or there was some other problem.  In the case of
      failure, an error message will have been written to the error
      channel from inside CPLEX.  In this example, the setting of
      the parameter CPXPARAM_ScreenOutput causes the error message to
      appear on stdout.  */

    if ( net == NULL ) {
        fprintf (stderr, "Failed to create network object.\n");
        goto TERMINATE;
    }

    /* Fill in the data for the problem.  Note that since the space for
      the data already exists in local variables, we pass the arrays
      directly to the routine to fill in the data structures.  */

    status = buildNetwork (env, net, converter.widgetNet,
                           converter.nnodes, converter.narcs,
                           converter.supply, converter.head, converter.tail,
                           converter.obj, converter.ub, converter.lb);

    // if(supply != NULL){
    // 	cout << "before not clear" << endl;
    // }

    if ( status ) {
        fprintf (stderr, "Failed to build network problem.\n");
        goto TERMINATE;
    }


    /* Optimize the problem and obtain solution. */

    status = CPXNETprimopt (env, net);
    if ( status ) {
        fprintf (stderr, "Failed to optimize network.\n");
        goto TERMINATE;
    }

    /* get network dimensions */

    narcs  = CPXNETgetnumarcs  (env, net);
    nnodes = CPXNETgetnumnodes (env, net);

    status = CPXNETsolution (env, net, &solstat, &objval,
                             converter.x, converter.pi, converter.slack, converter.dj);
    // cout << "status: " << status << endl;
    if ( status ) {
        // fprintf (stderr, "Failed to obtain solution.\n");
        goto TERMINATE;
    }

    /* Write the output to the screen. */

    // printf ("\nSolution status = %d\n", solstat);
    if (solstat != 1 && solstat != 6 && solstat != 14) {
        // cout << "status" << solstat << endl;
        status1 = -1;
        goto TERMINATE;
    }
    // printf ("Solution value  = %f\n\n", objval);

    status1 = 0;


TERMINATE:

    /* Free up the problem as allocated by CPXNETcreateprob, if necessary */

    if ( net != NULL ) {
        status = CPXNETfreeprob (env, &net);
        if ( status ) {
            fprintf (stderr, "CPXNETfreeprob failed, error code %d.\n", status);
        }
    }

    if ( env != NULL ) {
        status = CPXcloseCPLEX (&env);

        if ( status ) {
            char  errmsg[CPXMESSAGEBUFSIZE];
            fprintf (stderr, "Could not close CPLEX environment.\n");
            CPXgeterrorstring (env, status, errmsg);
            fprintf (stderr, "%s", errmsg);
        }
    }

    return (status1);

}
Пример #6
0
void Z3DNetworkEvaluator::updateNetwork()
{
  buildNetwork();
  initializeNetwork();
}