Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to fix some variables

    Posted 12/22/10 10:44 AM

    Originally posted by: newuser2010


    Hi, suppose there are 7000 binary variables, and from some information I can know 1500 binary variables are 1. How can I fix these variables in the preprocessing? For example, can I write something before
    minimize …….
    subject to {
    …….
    }

    Thank you.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: how to fix some variables

    Posted 12/22/10 11:12 AM
    Hi,

    let me give you a small example

    dvar int x in 0..5;
     
    execute
    {
     x.UB=4; 
     x.LB=4;
     // This sets x to the value 4
    }  
     
    maximize x;
    subject to
    {
     
    }
    


    And the solution will be x=4

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: how to fix some variables

    Posted 12/23/10 04:40 AM

    Originally posted by: SystemAdmin


    Hi,

    I made the experience that you might loose performace, if you
    set the lower und upper bound of several thousands of variables,
    as Alex described.

    An alternative way to tackle the problem is to set up a subset
    of variables for which you set up constraints that fix the
    variable.

    I.e. you will have sometrhing like (code is not tested)
    range numVars = 1..5000;
    dvar int x[numVars] in 0..5;
    {int} fixedVars = ... add some code to determine the fixed vars ...
     
    maximize sum(i in numVars ) x[i];
    subject to
    {
      // ... some other constraints ...
     
      // fix variables
      for(i in fixedVars )
       x[i] == 4;
    }
    


    You might try both. Both should yield the same solution.

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: how to fix some variables

    Posted 12/23/10 08:02 AM

    Originally posted by: newuser2010


    Hi, thanks for the reply.
    The reason why I do not want to put that in the constraints is that the fewer constraints, the less CPU time.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: how to fix some variables

    Posted 12/23/10 08:22 AM

    Originally posted by: SystemAdmin


    Hi,

    don't take that for granted. The reason why I proposed the approach
    was that this resulted in a lower overall CPU-time ...

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: how to fix some variables

    Posted 12/23/10 10:43 AM

    Originally posted by: newuser2010


    Hi Norbert,

    I wanna try that.
    When I debug it, it cannot step into the loop. Would you please help me to take a look? Thank you very much.

    The .mod file is:

    int nbProviders = ...; // Number of suppliers
    range providers = 1..nbProviders;
    int nbHours = ...; // Number of hours of auction
    range time = 1..nbHours;
    int Lproviders = ...;
    int minupproviders = ...;
    int Fproviders = ...;
    int mindownproviders = ...;

    dvar int Takeproviderstime in 0..1;

    execute {
    var p,t;
    for (p in providers) {
    if (L[p]>=1) {

    for (t in 1..L[p]) {
    Take[p][t] = 1;
    }
    }
    }

    for (p in providers) {
    if (F[p]>=1) {
    for (t in 1..F[p]) {
    Take[p][t] = 0;
    }
    }
    }
    }

    minimize ......
    subject to {
    ......
    }

    The .dat file is:

    nbProviders = 2;
    nbHours = 3;
    L=2,0;
    minup=3,3;
    F=0,1;
    mindown=3,2;
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: how to fix some variables

    Posted 12/27/10 03:44 AM

    Originally posted by: SystemAdmin


    Cheers,

    the code is not very readable. Would you please put the
    code into bracketing
    {code} some code {code}
    statements.
    What do you mean by "cannot step into the loop"?
    Is there an error message?

    Two points that I can see at the moment:
    for (t in 1..L[p]) {
    

    is not a valid syntax. It should be something like
    for (var t=1; t<=L[p]; t++) {
    


    Furthermore you assign some value to a decision variable:
    Take[p][t] = 1;
    

    This is invalid.
    Too what purpose?
    In case you want to fix the variable you should do this as
    described in this thread.
    Hope this will help.

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: how to fix some variables

    Posted 12/27/10 09:53 PM

    Originally posted by: newuser2010


    Thank you, Norbert.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: how to fix some variables

    Posted 10/24/11 07:00 PM

    Originally posted by: UDOPS


    HI, I am also interested in fixing variables, primarily not to speed solution, but to reduce memory consumption. I have a large model that solves quickly but exceeds memory frequently. I can decompose the model into steps and fix the variables in later steps. Will either of these suggested methods reduce the memory consumption relative to the same model with all variables active? Or will these methods consume as much or more memory than the same model unfixed.

    The alternative I suppose is for me to create alternative methods to subtract the fixed variable set from the active variable set and insert fixed values into the constraints to represent the fixed variable values.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: how to fix some variables

    Posted 10/24/11 09:54 PM

    Originally posted by: UDOPS


    Update: I tried it, and saw no reduction in memory. Looks like I actually have to remove the variables dynamically from the formulation.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer