Hiring company has the following requirement within a year;

week 1 to 5: 20

week 6 to 20: 40

week 21 to 40: 35

week 41 to 60: 55

week 61 to 80:75

week 81 to 100: 60

  • Training time for an employee is 4 weeks and they are unproductive at times.
  • An employee can work up to 20% overtime and 10% undertime in a week.
  • Overtime cost is 1.5 times the regular cost.
  • The regular cost is 10 per hour.
  • The hiring cost is $2000 per employee.
  • In week 1, the company has 20 employees.

    [1]: https://i.stack.imgur.com/2rjJ1.pngenter image description here

  • 2
    $\begingroup$ Let me hazard a guess that this is a school assignment, in which case you should show some evidence of effort, other than hoping a stranger on the internet will do it for you. $\endgroup$ – Mark L. Stone Apr 9 at 16:11
  • $\begingroup$ Hi @mark , I had this question in an interview for operations research analyst intern position , I have tried it many times but was not able to solve this , there is nothing other than knowledge ,that I am going to gain out of this $\endgroup$ – sudarsan vs Apr 9 at 16:22
  • 3
    $\begingroup$ Well, you've had some time to think about in a less-pressured environment than a job interview. So why don't you show us your efforts so far. Can you formulate a simplified version of this problem which avoids aspects which you don;t know how to deal with? $\endgroup$ – Mark L. Stone Apr 9 at 16:31
  • 2
    $\begingroup$ @sudarsanvs, Do you have a mathematical formulation on your problem? If so, would you share it? $\endgroup$ – A.Omidi Apr 9 at 22:27
  • 2
    $\begingroup$ Following the comments other guys provided, I think the right path is to formulate the problem first, and then implement it in Cplex. Try to formulate the problem, and share with us, if you stuck somewhere. Then, try to implement the model in Cplex. $\endgroup$ – Mostafa Apr 9 at 23:03

In general it's good to write some equations before. But when you rely on an algebraic modeling language like OPL you may also directly try your ideas.

Disclosure: I am the author of the linked article.

Let me share a starting point with OPL CPLEX


range weeks=1..100;

tuple need
  int startweek;
  int endweek;
  int quantity;

{need} needs={<1,5,20>,<6,20,40>,<21,40,35>,

int demand[w in weeks]=
  first({n | n in needs : n.startweek<=w && w<=n.endweek}).quantity;

int trainingTime=4;
float overtime=0.2;
float undertime=-0.1;
float overtimecost=1.5;
float cost=10;
float hiringcost=2000;
int startEmployees=20;
int nbhours=8;

dvar int+ hire[weeks];
dvar int+ nbEmployees[weeks];
dvar float underover[weeks];

dexpr float hiringCost=hiringcost*sum(w in weeks) hire[w];
dexpr float salaryCost=nbhours*cost*sum(w in weeks)nbEmployees[w];
dexpr float underovertimeCost=nbhours*cost*
  sum(w in weeks) (overtimecost*(underover[w]>=0)*underover[w]+

minimize hiringCost+salaryCost+underovertimeCost;
subject to
  // stating point
  forall(i in 1..trainingTime)nbEmployees[i]==startEmployees;
  // satisfy demand
  forall(w in weeks) 
  // undertime and overtime
  forall(w in weeks) 
  // hiring employees
  forall(i in weeks:(i+trainingTime) in weeks ) 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.