Decision Optimization

 View Only
  • 1.  Error when adding constraint

    Posted Wed June 22, 2022 09:07 AM

    Hi all,

    I have an error saying:

    Unhandled exception at 0x7c809e8a in NIMCAsst.exe: 0xC0000005: Access violation reading location 0x154c6000.

    I want to save the constraint into a two dimensional array flowConstraints_1b so I can update the constraint easily in the future. But my program crashes
    when I assign an IloRange to an element of this two dimensional array.

    Could you tell me what is the reason and how can I solve it?

    	flowConstraints_1b = IloArray<IloRangeArray>(env, info.numberStations);
    	
    	for (int i = 0; i < info.numberStations; i++) {
    		
    		cout << i << endl;
    		flowConstraints_1b.add(IloRangeArray(env, info.numberStations));
    		
    		for (int j = 0; j < info.numberStations; j++)
    			if (i != j)
    			{
    
    				ostringstream os_1b;
    				//error: access violation reading location 
    				flowConstraints_1b[i][j] = IloRange(env, 0, info.arrivalRate_lambdaij[i][j] * openPairStations[i][j]
    					- info.travelTimes_1muyij[i][j] * f[i][j], 0, os_1b.str().c_str());
    				
    
    				model.add(flowConstraints_1b[i][j]);
    
    			}
    	}
    


    ------------------------------
    Minh Vu
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Error when adding constraint

    Posted Wed June 22, 2022 10:44 AM
    It is solved. It should be
    		flowConstraints_1b[i] = IloRangeArray(env, info.numberStations);
    ​


    ------------------------------
    Minh Vu
    ------------------------------