Problem:bacp Data int n_courses; int n_periods; int load_per_period_lb; int load_per_period_ub; int dp=load_per_period_ub-load_per_period_lb; int courses_per_period_lb; int courses_per_period_ub; int course_load[n_courses]; int n_prereqs; int prereqs[n_prereqs,2]; int fact_dif=6; int n_periods2=n_periods-fact_dif; int load_per_period_lb2=(load_per_period_lb*n_periods) Div n_periods2; int load_per_period_ub2=(load_per_period_ub*n_periods) Div n_periods2; int dp2=load_per_period_ub2-load_per_period_lb2; int courses_per_period_lb2=(courses_per_period_lb*n_periods) Div n_periods2; int courses_per_period_ub2=(courses_per_period_ub*n_periods) Div n_periods2; int dp3=courses_per_period_ub2-courses_per_period_lb2; Domains Dom dperiods=[1..n_periods2]; Dom dload=[load_per_period_lb2..load_per_period_ub2]; Dom dcourses=[courses_per_period_lb2..courses_per_period_ub2]; Variables IntVar CURp[n_courses]::dperiods; IntVar period_load[n_periods2]::dload; IntVar period_courses[n_periods2]::dcourses; IntVar objectiu::dload; IntVar objectiu2::dcourses; Constraints %%% Every course must be assigned to exactly one period. %%% This constraint is implicit in this modelling. %%% The number of courses per period must be within bounds %%% (i.e. the domain of period_courses[p]). Forall(p in [1..n_periods2]) { Count([CURp[c] | c in [1..n_courses]],p,period_courses[p]); }; %%% The workload in each period must be within bounds %%% (i.e. the domain of period_load[p]). Forall(p in [1..n_periods2]) { Sum([If_Then_Else(CURp[c]=p)(course_load[c])(0)| c in [1..n_courses]],period_load[p]); }; %%% Prerequisites are desirable but non-mandatory. %%% Each prerequisite (np) is posted as a soft constraint with %%% its label (pre[np]) and a violation cost of 1. Forall(np in [1..n_prereqs]) { #pre[np]:(CURp[prereqs[np,1]] > CURp[prereqs[np,2]])@; }; %%% If a prerequisite is violated then the corequisite constraint is mandatory. Forall(np in [1..n_prereqs]) { (CURp[prereqs[np,1]] > CURp[prereqs[np,2]]) Or (CURp[prereqs[np,1]] = CURp[prereqs[np,2]]); }; %%% We post as soft constraints each unit of distance between %%% load_bound and load_per_period_lb. Forall(p in [1..n_periods2]) { period_load[p]=