Sure,

My intro text was... a bit terse I'll agree, but hopefully the the code
explains it.

A possible metaphor for the model is a worker who comes in for three hours
a few days a week.
 - the worker can arrive at 1,2 or 3 o'clock
 - must work 3 sequential hrs in a workday
 - the worker can come in on whatever day he wants but is paid most if it
is 3 days since he last worked
 - the worker must work 6 hours total in a 5 day period.
var Y represents when the worker is present where the row is the day, and
the column is the hour of that day.

The optimization problem I'm trying to solve is like a distance
optimization. In my case I have a two dimensional binary array (Y) which
has 1's in some rows(working), and not in others (not working). I want a
cost function based on the distance between rows having data (distance
between days worked). So, for example in the code I show an array have 1's
in row 0 and 3, this might have a value of 1.0, whereas if the data were in
row 1 and 3 the cost should be lower. What is not clear to me is how to use
MathProg to weight based on the difference in the row index.

The other part was how to use MathProg to generate a specific pattern
within a row in a binary array. In my trivial example I'm saying my worker
must work 3 sequential hours, so in my case a the array is a 5x5, a row has
5 element and my pattern happens to be 3 sequential ones so
1 1 1 0 0, 0 1 1 1 0, or 0 0 1 1 1 would all be valid rows

My program succeeds in requiring that there are 3 1's in a given row (3
hours worked in a day), but I can't think of a way of writing a constraint
to enforce that only the three candidates above would be feasible (i.e.
that the workers hours are sequential).


Is that clearer?

Thanks,

Eric


On Fri, Mar 11, 2016 at 11:32 AM, Andrew Makhorin <[email protected]> wrote:

>
> > I have what seems like a simple problem, but I'm not quite sure how to
> > address it.
> > I have complex model that I've simplified below. Basically I have a
> > MIP problem where I would like to have
> >  - three elements in a row and
> >  - I would like the non-zero rows optimally spaced.
> >
>
> Your question is unclear. Please formulate it more precisely.
>
>
>
>
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to