## Create relationship between sets

Problems with syntax of GAMS
User
Posts: 6
Joined: 1 month ago

### Create relationship between sets

Good day, please I need help to establish relationship between sets but I don't know how to go about it. It's a job scheduling problem.
An example is shown below.
Sets
j Current job /j1*j10/
h last job before the current /h1*h10/

I want to establish a relationship between h and j such a the relationship shown below. If the current job is J6 and it has finish processing and the next job is j2. While on job 6 set j is 6 but immediately it starts processing job 2, set j will pass its old value to h as 6 and the current job will have set j as 2.
h = ord (j)-1. (I don't know if this correct)
I want to express last job in terms of the current job. I don't even if this relationship is expressed as set, parameter or what.?
Thanks.
Last edited by adeniyi4adisa 2 weeks ago, edited 1 time in total.

User
Posts: 6
Joined: 1 month ago

### Re: Create relationship between sets

2 weeks ago
Good day, please I need help to establish relationship between sets but I don't know how to go about it. It's a job scheduling problem.
An example is shown below.
Sets
j Current job /j1*j10/
h last job before the current /h1*h10/
I want that, if job 6 is the current job and job 2 was the last one, my model will be able to pass the last job to h and the current job will be j.
I want to establish a relationship between h and j such a the relationship shown below.
h = ord (j)-1. (I don't know if this correct)
I want to express last job in terms of the current job. I don't even if this relationship is expressed as set, parameter or what.?
Thanks.

Renger
Posts: 585
Joined: 3 years ago

### Re: Create relationship between sets

Hi
You are aware that you can write j-1 as index?

Code: Select all

``````set j /j1*j10/;

parameter Job(j), Previousjob(j)

PreviousJob(j) = Job(j-1);
``````
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

User
Posts: 6
Joined: 1 month ago

### Re: Create relationship between sets

Thanks renger, you have been of great help to me. Though I have not finished working on your guide but it proved helpful.