Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problems when setting objcoef and constraint coef

    Posted 11/05/13 10:39 AM

    Originally posted by: GACNEU


    Please find my project in the attachment.

    I have a model in DistributionNetwork.mod.

    and i want to call the model in another model file SensitiveAnalyze.mod

    two problems i have here.

    firstly, in SensitiveAnalyze.mod, if coef vary from 0.1 to 1, such as "for(var coef = 1; coef<=1; coef=coef+0.1)"

    it shows "3DCs are selected" when coef = 1

    and if coef vary from 1.0 to 1.0, such as "for(var coef = 1; coef<=1; coef=coef+0.1)"

    it shows "1DCs are selected" when coef = 1

    how weird it is

    second, in the simple model DistributionNetwork.mod, i have a contraint named "ct"

    and i want to change its coef in SensitiveAnalyze, but errors are reported

    how to deal with this errors.

    Thanks a lot for you attention!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problems when setting objcoef and constraint coef

    Posted 11/05/13 01:03 PM

    hi,

    for the first question, numerical differences may lead to different equivalent questions

     

    for the second question:

    can you change

     

    Problem.ct.setCoef(Problem.X[j],coef*Problem.FixCost[j]);

    into

    cplex.setCoef(Problem.ct,Problem.X[j],coef*Problem.FixCost[j]);

     

    and

    ct:    TotalFixCost  = sum(j in PossibleDC)FixCost[j]*X[j];

    into

    ct:    TotalFixCost  - sum(j in PossibleDC)FixCost[j]*X[j]==0;

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Problems when setting objcoef and constraint coef

    Posted 11/07/13 09:34 AM

    Originally posted by: GACNEU


    Thanks a lot, it works to my second problem.

    As for the first problem, i built a simple example to demonstrate what i mean.

    in T.mod:

    dvar int X in 0 .. 10;
    dvar int Y in 0 .. 10;
    maximize X + Y;
    subject to{X + Y <= 10;}

    and in TT.mod:

    main
    {
      var source = new IloOplModelSource("T.mod");
     var cplex = new IloCplex();
     var def = new IloOplModelDefinition(source);
     var Problem= new IloOplModel(def,cplex);
     Problem.generate();
     for(var coef =  0.5; coef<=1.5; coef=coef+1)             //This make the coefficient of X equal to 0.5 and 1.5
     {
         writeln("-----------coef = ",coef,"-----------");
      cplex.setObjCoef(Problem.X,coef);
      cplex.solve();
      writeln("Objective Value = ", cplex.getObjValue());
      writeln("X=",Problem.X);
      writeln("Y=",Problem.Y);
     }
     Problem.end();
     def.end();
     cplex.end();
     source.end();

    In log, it says:

    -----------coef = 0.5-----------
    Objective Value = 10
    X=0
    Y=10
    -----------coef = 1.5-----------
    Objective Value = 15
    X=0
    Y=10

    Obviously, the objective value is right, but the value of decision variables are wrong,

    why and how?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Problems when setting objcoef and constraint coef

    Posted 11/08/13 02:54 AM

    Hi,

    we recommend to call postProcess:

     

    can you turn

     

    cplex.solve();
     writeln("Objective Value = ", cplex.getObjValue());

    into

    cplex.solve();
    Problem.postProcess();
    writeln("Objective Value = ", cplex.getObjValue());

    ?

     

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Problems when setting objcoef and constraint coef

    Posted 11/14/13 10:07 AM

    Originally posted by: GACNEU


    Grateful.  the problem is done.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer