Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 05:06 AM

    Originally posted by: JenBerlin


    Hi everyone,

    I am only just getting started with using CPLEX and have run into an issue in the constraint formulation.

    This may be a very silly question, but as a complete beginner I would really appreciate any help from more experienced users :)

     

    Without going into too much detail, I will try to explain what I am trying to do:

    Basically, I am trying to address two different properties of a tuple (month and period), and ensure that for each tuple of each possible combination of these two properties, a certain constraint is respected.

    The tuple itself contains a lot of information which I am addressing throughout the model. This is all part of a case study and the information was given. As you can see below, the tuple is called Combos and contains information about various combinations of months, periods and fuel types.

                           //  month,     period,               fuel,           revenue,      cost,     biomass (yes/no)  ,  calorific,     so2    )
      Combos  =  {<"June",   "WDPeak",   "Stockpile",      36.00,        42.56,        0,                               25.81,      0.0138    >,
                             <"June",    "WDPeak",   "Colombian",  36.00,        43.93,        0,                               25.12,      0.0070    >,

     

    The objective function works as it should, but unfortunately the constraints I am trying to impose are not respected in the solution given. No errors are showing when I run the configuration.

    I am pretty sure that it is a problem regarding the constraint formulation, as I am trying to address different tuple properties. It is very likely that I am not doing that in the correct way, however, I have been unable to find information about how to properly formulate them :(

     

    This is an example of a constraint as I currently wrote it:

    c1:
         forall (m in Months)
           forall (p in Periods)
             sum (x in Combos : m == x.month)
               sum (y in Combos : p == y.period)
                 Efficiency * production[y] <= AvailableHours[m][p] * PlantCapacity;

    The idea behind it was to say that for each combination of months and periods, it is not possible to produce more energy than the plant has capacity for, based on the hours available in this specific month/period combination.

     

    If you could give me any tips on why the constraint is not being respected and how I would need to formulate it, that would be very much appreciated.

    If any more information is required just let me know. I thought I would try to keep it short for now, but I would be happy to share the files as well if that would help you help me ;)

    Thanks a lot,

    Jennifer

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 11:05 AM

    What do you mean "the constraint is not respected"? Do you indeed get a solution that violates the constraints? Or do you get a solution that respects the constraints but you consider the solution infeasible? In that case you may be missing additional constraints.

    One way to figure out what exactly is going on is the following

    1. Add a settings file to your project and run configuration.
    2. In that settings file set Language->Run->Export format to "LP format".
    3. Run your model.
    4. A file <run configuration name>.lp will be created in your project directory. This file contains a human readable description of the model that is being solved.
    5. Look at that file and find the offending constraints. Then double check that they look like what you expect.

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 11:16 AM

    Not sure if this is the problem or even intended but in your constraint formulation every Combo will be appear twice in the left-hand side of the constraint: it will be picked once because it has a matching month and once because it has a matching period. If I understand correctly then you just want to sum over the Combos for which month and period match simultaneously? In that case the constraint should be this:

    c1:
         forall (m in Months)
           forall (p in Periods)
             sum (x in Combos : m == x.month && p == x.period)
               Efficiency * production[x] <= AvailableHours[m][p] * PlantCapacity;


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 12:24 PM

    Originally posted by: JenBerlin


    Ooooh Daniel, thank you so much! I tried everything I could think of to put something like an "and" there but I never would have guessed the "&&".

    I believe that will fix it, I will check once I'm back at the machine with the software :)


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 12:56 PM

    There is a table that lists all those operators. Go here: http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r5/index.jsp and then go to  IDE and OPL > Optimization Programming Language (OPL) > Language Quick Reference > OPL Operators and OPL Syntax > Operators.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Help a newbie - Constraint formulation?

    Posted Wed April 17, 2013 01:27 PM

    Originally posted by: JenBerlin


    Fantastic! That is so helpful, thanks a ton :)


    #CPLEXOptimizers
    #DecisionOptimization