Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem in CP with CPlex : Cannot extract expression

    Posted 03/30/20 01:27 PM
    Hello everyone !
    This looks like this is the first post to this discussion, so I guess I'm proud to inaugurate it.
    I am actually studying data science and more specifically constraints programming. My teacher has tasked me with creating a CPLex model that could schedule an entire basketball season with the objective of limiting the number of "breaks" (a team playing twice in a row at home or away). I am almost done with my model, but I'm facing an issue with one of my constraint : 

    I have a boolean dvar that takes a team and a week and that has the value true if the team is playing at home this week or false if it is playing away. In both cases, I'm trying to tell another integer dvar (that also takes a week and a team) to take the value of either this team's home stadium (which is represented by an integer) or of the opposite team's home stadium.

    This is how I represented it : 
    linkingStadiumsToRealStadiums:
      	forall(t in allTeams, w in firstPeriodWeeks) {
      	  (stadiumUsedQ1[t][w] == true) => (realStadiumQ1[t][w] == preferedStadium[t]);
      	  (stadiumUsedQ1[t][w] == false) => (realStadiumQ1[t][w] == preferedStadium[opponentFacedQ1[t][w]]);
    	  (stadiumUsedQ2[t][w] == true) => (realStadiumQ2[t][w] == preferedStadium[t]);
      	  (stadiumUsedQ2[t][w] == false) => (realStadiumQ2[t][w] == preferedStadium[opponentFacedQ2[t][w]]);  	  
      	}
    And this is the code initializing data and dvar : 
    int preferedStadium[1..totalTeams] = ...;
    
    dvar int opponentFacedQ1[t1 in allTeams][firstPeriodWeeks];
    dvar int opponentFacedQ2[t1 in allTeams][firstPeriodWeeks];
    
    dvar boolean stadiumUsedQ1[t1 in allTeams][firstPeriodWeeks];
    dvar boolean stadiumUsedQ2[t1 in allTeams][firstPeriodWeeks];
    
    dvar boolean stadiumUsedVSQ1[t1 in allTeams][t2 in allTeams];
    dvar boolean stadiumUsedVSQ2[t1 in allTeams][t2 in allTeams];
    
    dvar int realStadiumQ1[t1 in allTeams][firstPeriodWeeks] in 1..numberOfStadiums;
    dvar int realStadiumQ2[t1 in allTeams][firstPeriodWeeks] in 1..numberOfStadiums;


    Now, this is the error I'm getting : CP cannot extract expression for this constraint.

    I have no idea what the error is. I've been tweaking it bit by bit but so far I haven't had any success. I thought a fresh look by more experimented devs might be helpful. Thanks in advance for whatever advice you'll be able to give me :)
    Thanks in advance,
    Regards,
    Thomas

    ------------------------------
    Thomas Gervaise
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Problem in CP with CPlex : Cannot extract expression

    Posted 04/27/20 12:57 AM
    Boolean decision variables take values 0 and not, not false and true. Try replacing "true" and "false" in your constraints by 1 and 0. That should do the trick.

    ------------------------------
    Daniel Junglas
    ------------------------------