0

我在写作限制方面有问题。我有一个手机号码,4个资费套餐和9个月。目前,解决方案是为每个月提供不同的关税。我想写约束,以便解决方案为每个模型提供相同的关税

    //DATA
 {string} numbers = ...;//mobile phone number, id, FOR NOW ONLY ONE NUMBER
 {string} usageCategories = ...;//{"fixed""mobile""international""data"}

 tuple packageInfo { 
    string name;
    float price;
    float fixedMinutes;
    float mobileMinutes;
    float internationalMinutes;
    float data; 
 };

 {packageInfo} packages = ...;//tariff package info

 float UsageFixed[numbers] = ...;//fixed min used
 float UsageMobile[numbers] = ...;//mobile other min used
 float UsageInternational[numbers] = ...;//international numbers used
 float UsageData[numbers] = ...; //data traffic (kb)
 float taxfree[numbers] = ...; //tax free items
 float InternationalServices[numbers] = ...; //international services
 float pricePerMinute[usageCategories] = ...;//price per minute after minutes included in package

 //minutes included in package for each number...calculated in execute block overageFactor
 float overageFixed[numbers][packages];
 float overageMobile[numbers][packages];
 float overageInternational[numbers][packages];
 float overageData[numbers][packages];



 //DECISION VARS
 dvar boolean assign[numbers][packages];


 //overage amount
 execute overageFactor {

    for (var n in numbers) {
        for (var p in packages) {
            if (UsageFixed[n] < p.fixedMinutes)
                overageFixed[n][p] = 0;
            else overageFixed[n][p] = UsageFixed[n] - p.fixedMinutes;

            if (UsageMobile[n] < p.mobileMinutes)
                overageMobile[n][p] = 0;
            else overageMobile[n][p] = UsageMobile[n] - p.mobileMinutes;

            if (UsageInternational[n] < p.internationalMinutes)
                overageInternational[n][p] = 0;
            else overageInternational[n][p] = UsageInternational[n] - p.internationalMinutes; 

            if (UsageData[n] < p.data)
                overageData[n][p] = 0;
            else overageData[n][p] = UsageData[n] - p.data;     
        }   
    }

};

 dexpr float packagesCost = sum (n in numbers, p in packages) p.price * assign[n][p]; //package cost

 //overage costs
 dexpr float fixedOverageCost[p in packages, n in numbers] = 
                                    overageFixed[n][p] * assign[n][p] * pricePerMinute["fixed"];
 dexpr float mobileOverageCost[p in packages, n in numbers] =
                                    overageMobile[n][p] * assign[n][p] * pricePerMinute["mobile"];
 dexpr float internationalOverageCost[p in packages, n in numbers] = 
                                    overageInternational[n][p] * assign[n][p] * pricePerMinute["international"];
 dexpr float dataOverageCost[p in packages, n in numbers] = 
                                    overageData[n][p] * assign[n][p] * pricePerMinute["data"];

 dexpr float cost = packagesCost + sum (p in packages, n in numbers)
                            (fixedOverageCost[p,n] + mobileOverageCost[p,n] + internationalOverageCost[p,n] + dataOverageCost[p,n])
                       + sum (n in numbers) taxfree[n]
                       + sum (n in numbers) InternationalServices[n];

 //OBJECTIVE
 minimize cost;



 //CONSTRAINTS
 subject to {

    //one package for each number
    forall (n in numbers)
        sum (p in packages) assign[n,p] == 1;

    //every month same package

    ?????????????????????????

 };


 //Data display
 tuple assignedPackage {
    string id;
    string package; 
 };

 {assignedPackage} assignedPackages = {<i,p.name> | i in numbers, p in packages : assign[i,p] == 1};

 execute dataDisplay {
    writeln ("Assign following packages to users:");
    for (var i in assignedPackages)
        writeln (i); 
 }

 current solution:

 <"7" "VPN ZA SVE S">
 <"6" "VPN ZA SVE L">
 <"8" "VPN ZA SVE S">
 <"9" "VPN ZA SVE S">
 <"10" "VPN ZA SVE L">
 <"11" "VPN ZA SVE M">
 <"12" "VPN ZA SVE M">
 <"1" "VPN ZA SVE S">
 <"2" "VPN ZA SVE M">
4

0 回答 0