[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Help-glpk] Newbie Question

**From**: |
Andrew Makhorin |

**Subject**: |
Re: [Help-glpk] Newbie Question |

**Date**: |
Mon, 11 Aug 2008 15:14:28 +0400 |

>* I am trying to write a model to maximize overall output when selecting*
>* personnel given a budget, the salary of each potential person and*
>* their output ability.*
>* *
>* The problem I have is writing a rule where one person will be*
>* choosen as team leader and their output will be calculated as double.*
>* *
>* Please, could someone help me with this?*
>* *
>* Thanks.*
>* *
>* /* sets */*
>* set PERSON;*
>* set POSITIONS;*
>* /* parameters */*
>* param num_of_positions {i in POSITIONS};*
>* param salary {i in PERSON};*
>* param output {i in PERSON};*
>* param position {i in PERSON, j in POSITIONS};*
>* /* decision variables: yi, i in {1,..,7}. yi = 1 -> person i is hired */*
>* var y {i in PERSON} binary >=0;*
>* /* objective function */*
>* maximize z: sum{i in PERSON} output[i]*y[i];*
>* /* Constraints */*
>* s.t. pos{j in POSITIONS}: sum{i in PERSON} *
>* position[i,j]*y[i] = num_of_positions[j];*
>* s.t. people: sum{i in PERSON} y[i] = 12;*
>* s.t. budget: sum{i in PERSON} salary[i]*y[i] <= 1150000;*
>* data;*
>* set PERSON := 1 2 3 ... 100;*
>* set POSITIONS := A B C D E;*
>* *
>* param num_of_positions :=*
>* A 1*
>* B 5*
>* C 3*
>* D 2*
>* E 1;*
>* *
>* param salary:=*
>* 1 90000*
>* 2 90000*
>* 3 70000*
>* .*
>* .*
>* 98 61000*
>* 99 58000*
>* 100 67000;*
>* *
>* param output:=*
>* 1 22*
>* 2 93*
>* 3 14*
>* .*
>* .*
>* 98 41*
>* 99 10*
>* 100 16;*
>* param position: A B C D E:=*
>* 1 1 0 0 0 0*
>* 2 0 0 1 0 0*
>* 3 0 1 0 0 0*
>* .*
>* .*
>* 98 0 1 0 0 0*
>* 99 0 0 0 0 1*
>* 100 1 0 0 0 0;*
If I correctly understand your model:
var leader{i in PERSON}, binary;
/* leader[i] = 1 means that person i is a leader */
s.t. foo{i in PERSON}: leader[i] <= y[i];
/* person i cannot be a leader, if he is not hired */
s.t. bar: sum{i in PERSON} leader[i] = 1;
/* there must be exactly one leader */
maximize z: sum{i in PERSON} output[i]*(y[i] + leader[i]);