Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Solving two Models

    Posted Wed August 12, 2009 01:01 AM

    Originally posted by: SystemAdmin


    [xellos00 said:]

    Hello to all, i'm new to this Optimization Software, i could make it solve a problem changing the data automatically, so you know, i read the manual.
    The problem is about two parts, and in the program that i could run was all solve together, but now i need to solve the same problem, but separately. The thing is, to solve it separately i need that the variables from the first part become data for the second part. I made the arrangements in the .mod file so those variables now are data, and separate the two parts in different .mod files and calling them from a different .mod file called Main.mod. The first part is solve fine, but the second part is reading everything (i think), but the solution is impossible according with the constraint of the .mod file.

    As you can see i made a large amount of vars that are meaningless, but it was to try to make it work. The result at the end is that the constraints in the "Semanal.mod" file don't apply. But the cplex solve it just fine.

    Here is the main model:

    main{

    var source = new IloOplModelSource("Separado.mod");
    var def = new IloOplModelDefinition(source);
    var Cplex = new IloCplex();
    var mensual = new IloOplModel(def, Cplex);
    var data = new IloOplDataSource("Separado.dat");

    mensual.addDataSource(data);
    mensual.generate();
    Cplex.solve();

    //Meaningless vars

    var produccionvalues = mensual.produccion;
    var inventariovalues = mensual.inventario;
    var backordervalues = mensual.backorder;
    var horas_extra_produccionvalues = mensual.horas_extra_produccion;
    var horas_normales_produccionvalues = mensual.horas_normales_produccion;
    var cantidad_subcontratacionvalues = mensual.cantidad_subcontratacion;
    var trabajadores_despedidosvalues = mensual.trabajadores_despedidos;
    var trabajadores_contratadosvalues = mensual.trabajadores_contratados;
    var trabajadores_actualesvalues = mensual.trabajadores_actuales;
    var trabajadores_horas_extrasvalues = mensual.trabajadores_horas_extras;

    mensual.end();

    //Second Part

    var source1 = new IloOplModelSource("Semanal.mod");
    var def1 = new IloOplModelDefinition(source1);
    var Cplex1 = new IloCplex();
    var semanal = new IloOplModel(def1, Cplex1);
    var data1 = new IloOplDataSource("Semanal.dat");

    semanal.addDataSource(data1);
    semanal.generate();

    //Next Iteration

    var def2 = semanal.modelDefinition;
    var data2 = semanal.dataElements;

    semanal = new IloOplModel(def2, Cplex1);
    semanal.addDataSource(data2);
    semanal.generate();

    //Changing the data to solve the new model

    for (var x in semanal.mes){
    for(var i in data2.producto){

    data2.produccion[i][x] = produccionvalues[i][x];
    data2.inventario[i][x] = inventariovalues[i][x];
    data2.backorder[i][x] = backordervalues[i][x];
    data2.horas_extra_produccion[i][x] = horas_extra_produccionvalues[i][x];
    data2.horas_normales_produccion[i][x] = horas_normales_produccionvalues[i][x];
    data2.cantidad_subcontratacion[i][x] = cantidad_subcontratacionvalues[i][x];
    }
    data2.trabajadores_despedidos[x] = trabajadores_despedidosvalues[x];
      data2.trabajadores_contratados[x] = trabajadores_contratadosvalues[x];
      data2.trabajadores_actuales[x] = trabajadores_actualesvalues[x];
      data2.trabajadores_horas_extras[x] = trabajadores_horas_extrasvalues[x];
      }

    semanal.addDataSource(data2);
    semanal.generate();

    if (Cplex1.solve())
    writeln("success");
    else writeln("Cuack");

    }


    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Solving two Models

    Posted Fri August 21, 2009 01:59 AM

    Originally posted by: SystemAdmin


    [xellos00 said:]

    Ok, i didn't find the solution, I can't understand why the problem says that have no solution. When i solve it all together it finds it perfectly, but separately can't find it.

    For the separate problem i copy the results from the first model into the data of the second, it took me a while but i need it to check if the script was right. Apparently it's right how it is now.

    Any ideas why this happens Please?
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Solving two Models

    Posted Thu August 27, 2009 07:15 AM

    Originally posted by: SystemAdmin


    [xellos00 said:]

    Finally... problem solve!!
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: Solving two Models

    Posted Sat October 03, 2009 08:23 AM

    Originally posted by: SystemAdmin


    [nnrr said:]

    Hi,
    i am having the same problem I want to access the values of my dvar after solving a model and then using those values. OPL shows me an error of not recognizing the name of my variable if I try to access it by linking it with the name of my data like you seemed to have done.

    I found the info on Accessing decision variables, the one that uses IloNumVar. But I can bearly understand what are the names of the variables in those examples.

    Could you let me know how you solve this issue? Did you use the dataElement routines? or the IloNumVal, or something else? I should also add that my variable is an array.

    Thank you
    nnrr
    #DecisionOptimization
    #MathematicalProgramming-General


  • 5.  Re: Solving two Models

    Posted Tue October 13, 2009 03:34 AM

    Originally posted by: SystemAdmin


    [kenalipandeglang said:]

    Hi,
    I have no idea for this problem.

    cheers,
    #DecisionOptimization
    #MathematicalProgramming-General