objective and constraint

233 views
Skip to first unread message

Manal AL-Mousa

unread,
May 10, 2021, 2:09:56 PM5/10/21
to AMPL Modeling Language
welcome everybody

   I have a problem

I would like to help with it, please

I created a form using ampl

In the objective and constraint

Can you help me write it in algebraic form

I did not write a form previously in the algebraic form, and it contains more than one index
.
.
thank you.


code.pdf

AMPL Google Group

unread,
May 11, 2021, 3:59:59 PM5/11/21
to AMPL Modeling Language
Do you mean that you would like to convert your AMPL model to a mathematical statement of your objective and constraints -- for example, using Σ signs instead of AMPL's "sum" operator? Then your objective function could be

dc9f0b2f1f94459a1ecc6b4aabcbe3b3.png

and constraint c4 could be

efebb0c4810fd9b384247349b38bb52a.png

If you want it to look more like a traditional math formulation, you could replace names like "door", "cost", and "trans_1" by single letters.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}

Manal AL-Mousa

unread,
May 11, 2021, 4:33:41 PM5/11/21
to am...@googlegroups.com
Yes that what I means

Thank you for write objective functions and c4 in algebraic form 

Can you help me please in the other constraints (c1,c2,c3,c5)

I need to write this constraints in the algebraic forms

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1509205583-4385901081-1620763196-1424910271%40helpscout.net.

AMPL Google Group

unread,
May 12, 2021, 10:38:55 AM5/12/21
to AMPL Modeling Language
I intended that c4 would serve as an example of how to write a constraint mathematically. By studying it, you can figure out how to write the other constraints.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Tue, May 11, 2021 at 8:33 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Yes that what I means

Thank you for write objective functions and c4 in algebraic form

Can you help me please in the other constraints (c1,c2,c3,c5)

I need to write this constraints in the algebraic forms

في ثلاثاء، ١١ مايو، ٢٠٢١ في ١٠:٥٩ م، كتب AMPL Google Group <am...@googlegroups.com>:

On Tue, May 11, 2021 at 7:59 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Do you mean that you would like to convert your AMPL model to a mathematical statement of your objective and constraints -- for example, using Σ signs instead of AMPL's "sum" operator? Then your objective function could be

dc9f0b2f1f94459a1ecc6b4aabcbe3b3.png

and constraint c4 could be

efebb0c4810fd9b384247349b38bb52a.png

If you want it to look more like a traditional math formulation, you could replace names like "door", "cost", and "trans_1" by single letters.


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 13, 2021, 11:13:49 AM5/13/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

thank you to write objective function and the constraint c4 In the previous

I tried to write the restrictions in algebraic form

Can you correct it for me please

and I have a question when viewing results

What can I change in the restrictions to obtain a result in which the students of different courses are not mixed in the same class?

 

Or how can I write a new restrictions to obtain a result in which the students of different courses are not mixed in the same class?

 

I need some help as well as writing this restrictions

 

Thank you …

 

Objective function.pdf

AMPL Google Group

unread,
May 14, 2021, 1:12:55 PM5/14/21
to AMPL Modeling Language
I looked quickly at your algebraic description, and did not see any corrections that were needed.

Since I am not familiar with your application, I cannot say exactly how you should add a constraint so that "students of different courses are not mixed in the same class". I can suggest that the following approach often works:
  • Add a binary variable -- like "var CourseClass {k in courses, j in class} binary;" -- that equals 1 if course k uses class j, and 0 otherwise.
  • To prevent mixing, write a constraint indexed over {j in class} that says sum {k in courses} CourseClass[k,j] <= 1.
  • To relate the CourseClass variables to the trans_1 variables, add a constraint that says if CourseClass[k,j] is 0, then no students from course k can be assigned to class j. This would be something like sum {i in door} trans_1[i,k,j] <= demand[j] * CourseClass[k,j].
After you write the needed constraints in AMPL, you should run the model again with your data, and confirm that you get an acceptable solution.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Thu, May 13, 2021 at 3:14 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

thank you to write objective function and the constraint c4 In the previous

I tried to write the restrictions in algebraic form

Can you correct it for me please

and I have a question when viewing results

What can I change in the restrictions to obtain a result in which the students of different courses are not mixed in the same class?

Or how can I write a new restrictions to obtain a result in which the students of different courses are not mixed in the same class?

I need some help as well as writing this restrictions

Thank you …

On Wed, May 12, 2021 at 2:38 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I intended that c4 would serve as an example of how to write a constraint mathematically. By studying it, you can figure out how to write the other constraints.


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 14, 2021, 3:12:03 PM5/14/21
to am...@googlegroups.com
Hmm, thank you for your suggestions and help me solve this problem, but I don't know what you mean by indexed constraints , I am not a program specialist and I have not studied it extensively, can you help me write the indexed constraints and what they mean and how they differ from the normal restrictions

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

Manal AL-Mousa

unread,
May 14, 2021, 4:40:01 PM5/14/21
to AMPL Modeling Language
i'm tried to write the constraint to relate the CourseClass variables to the trans_1 variables,


But I have an error that keeps popping up and I don't know the cause of this error and how to fix it

Can you help me with this constraint to discover the error and how to fix it

thank you ...
5.PNG
4.PNG

AMPL Google Group

unread,
May 16, 2021, 1:30:49 PM5/16/21
to AMPL Modeling Language
You need to say that there is a c7 constraint for each member of {j in class, k in courses}:

subject to c7 {j in class, k in courses}:
sum {i in door} trans_1[i,k,j] <= demand[j] * courses_class[k,j];


An indexed constraint is one that has an indexing expression { . . . } after the constraint name. All of your constraints except c1 are indexed.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Fri, May 14, 2021 at 8:40 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
i'm tried to write the constraint to relate the CourseClass variables to the trans_1 variables,

But I have an error that keeps popping up and I don't know the cause of this error and how to fix it

Can you help me with this constraint to discover the error and how to fix it

thank you ...

On Fri, May 14, 2021 at 7:12 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hmm, thank you for your suggestions and help me solve this problem, but I don't know what you mean by indexed constraints , I am not a program specialist and I have not studied it extensively, can you help me write the indexed constraints and what they mean and how they differ from the normal restrictions

On Fri, May 14, 2021 at 5:12 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I looked quickly at your algebraic description, and did not see any corrections that were needed.

Since I am not familiar with your application, I cannot say exactly how you should add a constraint so that "students of different courses are not mixed in the same class". I can suggest that the following approach often works:
  • Add a binary variable -- like "var CourseClass {k in courses, j in class} binary;" -- that equals 1 if course k uses class j, and 0 otherwise.
  • To prevent mixing, write a constraint indexed over {j in class} that says sum {k in courses} CourseClass[k,j] <= 1.
  • To relate the CourseClass variables to the trans_1 variables, add a constraint that says if CourseClass[k,j] is 0, then no students from course k can be assigned to class j. This would be something like sum {i in door} trans_1[i,k,j] <= demand[j] * CourseClass[k,j].
After you write the needed constraints in AMPL, you should run the model again with your data, and confirm that you get an acceptable solution.


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 16, 2021, 1:49:40 PM5/16/21
to am...@googlegroups.com
Thank you very much for this clarification, but I have a problem that I have never previously written an indexed constraint , can you write one of the  indexed constraint for me in an indexed manner so that I can see the way of writing, and then I do all the remaining  indexed constraint in the same way, because I have no experience with that.

When writing  indexed constraint, does something change in the model other than restrictions?  Are there other adjustments that I need to make in the model when writing indexed constraint?


--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

Manal AL-Mousa

unread,
May 16, 2021, 3:38:15 PM5/16/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

Thank you for all your previous help and clarifications

I wrote down the restrictions but I'm still facing the same problem, I don't know what to do

Why does this problem occur

Why are students mixed from different courses in the same classroom?

I don't want that to happen

I want students of one course in one classroom without mixing with students of the other course in the same classroom

Please see at the classroom B(8-10) course students have been mixed in

I have tried a lot to find a solution to this problem but I don't know what to do

I thought a lot and could not find a solution to this problem

Thank you again.
code.pdf

AMPL Google Group

unread,
May 17, 2021, 7:30:40 PM5/17/21
to AMPL Modeling Language
The message from the solver explains the problem:

ampl: model covid-19.mod;
ampl: data covid-19.dat;
ampl: solve;
MINOS 5.51: ignoring integrality of 52 variables

The MINOS solver does not support integer variables, including variables defined as "binary". As a result it ignores the "binary" restriction, and gives a solution where the courses_class values for B8-10 are 0.433333 and 0.566667. That allows the two courses to be mixed in classroom B8-10.

To avoid this problem, use a solver that can find an optimal solution subject to all binary variables being 0 or 1, such as CPLEX, Gurobi, Xpress, or CBC.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Sun, May 16, 2021 at 7:38 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

Thank you for all your previous help and clarifications

I wrote down the restrictions but I'm still facing the same problem, I don't know what to do

Why does this problem occur

Why are students mixed from different courses in the same classroom?

I don't want that to happen

I want students of one course in one classroom without mixing with students of the other course in the same classroom

Please see at the classroom B(8-10) course students have been mixed in

I have tried a lot to find a solution to this problem but I don't know what to do

I thought a lot and could not find a solution to this problem

Thank you again.

في الأحد، 16 مايو 2021 في تمام الساعة 8:49:40 م UTC+3، كتب ‪Manal AL-Mousa‬‏ رسالة نصها:

Thank you very much for this clarification, but I have a problem that I have never previously written an indexed constraint , can you write one of the indexed constraint for me in an indexed manner so that I can see the way of writing, and then I do all the remaining indexed constraint in the same way, because I have no experience with that.

When writing indexed constraint, does something change in the model other than restrictions? Are there other adjustments that I need to make in the model when writing indexed constraint?

في أحد، ١٦ مايو، ٢٠٢١ في ٨:٣٠ م، كتب AMPL Google Group <[url=]am...@googlegroups.com>:

You need to say that there is a c7 constraint for each member of {j in class, k in courses}:

subject to c7 {j in class, k in courses}:
sum {i in door} trans_1[i,k,j] <= demand[j] * courses_class[k,j];

An indexed constraint is one that has an indexing expression { . . . } after the constraint name. All of your constraints except c1 are indexed.

--
Robert Fourer
On Sun, May 16, 2021 at 5:49 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thank you very much for this clarification, but I have a problem that I have never previously written an indexed constraint , can you write one of the indexed constraint for me in an indexed manner so that I can see the way of writing, and then I do all the remaining indexed constraint in the same way, because I have no experience with that.

When writing indexed constraint, does something change in the model other than restrictions? Are there other adjustments that I need to make in the model when writing indexed constraint?

في أحد، ١٦ مايو، ٢٠٢١ في ٨:٣٠ م، كتب AMPL Google Group <am...@googlegroups.com>:

On Sun, May 16, 2021 at 5:30 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You need to say that there is a c7 constraint for each member of {j in class, k in courses}:

subject to c7 {j in class, k in courses}:
sum {i in door} trans_1[i,k,j] <= demand[j] * courses_class[k,j];


An indexed constraint is one that has an indexing expression { . . . } after the constraint name. All of your constraints except c1 are indexed.


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 18, 2021, 6:30:20 AM5/18/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

I would like to thank you for explaining many things to me on the model , I am so happy

Now I see a nice results with the program

Currently, I am thinking about how I can develop the model

In the group that was defined as courses, I had only two courses, and these courses had data for only one day.

If I have a full schedule for a number of days (Sunday - Monday - Tuesday - Wednesday - Thursday)

I have a different number of courses every day

These courses have different times
Each course has a specific time of two hours

How can I develop the model with this information so that I transfer students without mixing them from different courses in the same classroom?

I thought about adding a new group that expresses the days (Sunday - Monday - Tuesday - Wednesday - Thursday)

Then I add a parameter in which I write the days of the week from Sunday to Thursday

But I encountered a problem, how do I link the group that expresses different days of the week with different courses that have different times

I have not previously written anything like this in the program

Mr. Robert Fourer, Please can you suggest some ideas for this development

thank you so much.
code.pdf

AMPL Google Group

unread,
May 20, 2021, 8:32:51 AM5/20/21
to AMPL Modeling Language
Here are some ideas, but you will have to take responsibility for working out the details:

You could start by just considering different times on one day. Define a new set "time" and add it to the indexing wherever that is appropriate in your model, for example "param capacity {i in door, t in time} >= 0;" and "var trans_1 {i in door, k in courses, j in class, t in time} >= 0;". You will also have to add indexing over "time" in your constraints (including the ones that limit each classroom to one course) and you will have to expand your data to represent courses at different times.

When your formulation is complete, examine your solutions to see whether they are acceptable. If not, you may have to consider adding constraints.

After you have this working, you can consider further expanding the model, either by letting the members of "time" represent times on different days, or by adding a new set "day".


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Tue, May 18, 2021 at 10:30 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

I would like to thank you for explaining many things to me on the model , I am so happy

Now I see a nice results with the program

Currently, I am thinking about how I can develop the model

In the group that was defined as courses, I had only two courses, and these courses had data for only one day.

If I have a full schedule for a number of days (Sunday - Monday - Tuesday - Wednesday - Thursday)

I have a different number of courses every day

These courses have different times
Each course has a specific time of two hours

How can I develop the model with this information so that I transfer students without mixing them from different courses in the same classroom?

I thought about adding a new group that expresses the days (Sunday - Monday - Tuesday - Wednesday - Thursday)

Then I add a parameter in which I write the days of the week from Sunday to Thursday

But I encountered a problem, how do I link the group that expresses different days of the week with different courses that have different times

I have not previously written anything like this in the program

Mr. Robert Fourer, Please can you suggest some ideas for this development

thank you so much.
On Mon, May 17, 2021 at 11:30 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
The message from the solver explains the problem:

ampl: model covid-19.mod;
ampl: data covid-19.dat;
ampl: solve;
MINOS 5.51: ignoring integrality of 52 variables

The MINOS solver does not support integer variables, including variables defined as "binary". As a result it ignores the "binary" restriction, and gives a solution where the courses_class values for B8-10 are 0.433333 and 0.566667. That allows the two courses to be mixed in classroom B8-10.

To avoid this problem, use a solver that can find an optimal solution subject to all binary variables being 0 or 1, such as CPLEX, Gurobi, Xpress, or CBC.


--
Robert Fourer
am...@googlegroups.com
On Sun, May 16, 2021 at 7:38 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

Thank you for all your previous help and clarifications

I wrote down the restrictions but I'm still facing the same problem, I don't know what to do

Why does this problem occur

Why are students mixed from different courses in the same classroom?

I don't want that to happen

I want students of one course in one classroom without mixing with students of the other course in the same classroom

Please see at the classroom B(8-10) course students have been mixed in

I have tried a lot to find a solution to this problem but I don't know what to do

I thought a lot and could not find a solution to this problem

Thank you again.

Manal AL-Mousa

unread,
May 20, 2021, 4:15:49 PM5/20/21
to am...@googlegroups.com
hello  Mr. Robert Fourer

I want to ask

Is there a way to convert, write and run the ampl code in the Matlab program ?

because when I write my code and solve 
I can not see the result
Since I have demo version 
And it has limited for variables and constraints

Thank you.



--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/9JznqHXIYwk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1509205583-4412574399-1621513968-794653%40helpscout.net.

Manal AL-Mousa

unread,
May 21, 2021, 8:31:35 AM5/21/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

Show me this message
When I run the code in ampl program

Is there a solution to this problem without having to purchase the program?

Are there other programs that I can write the code in?

Or can I transfer the code to the Matlab program?

thank you.
5.PNG

AMPL Google Group

unread,
May 21, 2021, 4:18:44 PM5/21/21
to AMPL Modeling Language
AMPL is very different from MATLAB, so there is no automatic way to convert from AMPL to MATLAB. You would have to start over and rewrite your model in completely different way for MATLAB to be able to solve it.

You can run AMPL and many popular solvers for free on the NEOS Server, without the tight problem size limitations of the AMPL demo license you are currently using. (The only limits are 8 hours and 3 gigabytes of memory.) Also if you are using AMPL in an educational setting, see our AMPL for Courses and AMPL for Students pages for other free possibilities.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Fri, May 21, 2021 at 12:31 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

Show me this message
When I run the code in ampl program

Is there a solution to this problem without having to purchase the program?

Are there other programs that I can write the code in?

Or can I transfer the code to the Matlab program?

thank you.
On Thu, May 20, 2021 at 8:15 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

I want to ask

Is there a way to convert, write and run the ampl code in the Matlab program ?

because when I write my code and solve
I can not see the result
Since I have demo version
And it has limited for variables and constraints

Thank you.
On Thu, May 20, 2021 at 12:32 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Here are some ideas, but you will have to take responsibility for working out the details:

You could start by just considering different times on one day. Define a new set "time" and add it to the indexing wherever that is appropriate in your model, for example "param capacity {i in door, t in time} >= 0;" and "var trans_1 {i in door, k in courses, j in class, t in time} >= 0;". You will also have to add indexing over "time" in your constraints (including the ones that limit each classroom to one course) and you will have to expand your data to represent courses at different times.

When your formulation is complete, examine your solutions to see whether they are acceptable. If not, you may have to consider adding constraints.

After you have this working, you can consider further expanding the model, either by letting the members of "time" represent times on different days, or by adding a new set "day".


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 21, 2021, 7:21:53 PM5/21/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

First, I would like to thank you for directing me to NEOS server
I have had great results in code and I am very happy

i have added different times to the code in the ampl program
I have never had problems with this

Now I want to add different days
But I have a problem with this
i added a new set for days
i define the new set (days) in the parameters, objective function, and constraints
Now I have some parameters defined in three set such as

param capacity {i in door,t in time,d in days} >= 0;

param student {k in courses,t in time,d in days} >= 0;

When writing the data file

I don’t know how to write Parameters defined in three set

If I have a parameter defined on two set, I write the parameter in the data file in the form of an array of rows and columns

But when the parameter is defined in three set, how do I write it?
What do I type in the rows and what do I type in the columns?

Could you please explain this to me
You told me earlier that there are two ways to add different days
 (by letting the members of "time" represent times on different days, or by adding a new set "day")

Also, can you explain the first way to add days in the code?

thank you.
code.pdf

AMPL Google Group

unread,
May 24, 2021, 9:32:20 AM5/24/21
to AMPL Modeling Language
Chapter 9 of the AMPL book explains the different ways of writing data for a parameter indexed over 3 sets, with examples. See in particular the sections on "Lists of higher-dimensional sets and parameters" (page 148) and "Higher-dimensional tables" (page 157).

Your time set could contain, for example, "Monday1000", "Monday1130", "Monday1300", "Tuesday1030", "Tuesday1300", etc. -- so that each member represents a particular day at a particular time. Then you only need to add one set to your indexing.

Or, if the times are the same every day, you could have a separate time set ("1000", "1130", "1300", etc.) and day set ("Monday", Tuesday", etc.) and add both the time and day sets to your indexing, as in "param capacity {i in door, t in time, d in day} >= 0;".


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Fri, May 21, 2021 at 11:22 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

On Fri, May 21, 2021 at 8:18 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL is very different from MATLAB, so there is no automatic way to convert from AMPL to MATLAB. You would have to start over and rewrite your model in completely different way for MATLAB to be able to solve it.

You can run AMPL and many popular solvers for free on the NEOS Server, without the tight problem size limitations of the AMPL demo license you are currently using. (The only limits are 8 hours and 3 gigabytes of memory.) Also if you are using AMPL in an educational setting, see our AMPL for Courses and AMPL for Students pages for other free possibilities.


--
Robert Fourer
am...@googlegroups.com

Manal AL-Mousa

unread,
May 26, 2021, 4:01:04 PM5/26/21
to AMPL Modeling Language
hello  Mr. Robert Fourer

Thank you for my guidance to Chapter 9 in the book
But I had several problems that I couldn't understand
In my model I want to schedule days from Sunday to Thursday
And I have specific times that are the same every day

At first I defined a set for days 
set days := sunday monday tuesday wednesday thursday;

Then I defined a set of time
set time := 8-10 10-12 12-2;

Then I defined a set that connects the three groups (courses,days,time)
set scheduling within {courses,days,time};

Here I am not sure about my understanding
What is the meaning when I write a set within
How does the program read it?

In the parameters I didn't know exactly how to define scheduling in them

Do I define the set of days and time separately
Or I define tabulation in parameters

I really don't know how to do the tabulation and correctly enter it into the parameter and the objective function and constraints 

I tried to think about it a lot

In the data file

When writing the parameters defined on three groups

I tried to write it down, but I don't know if it is correct or not

I have some inquiries here
How do I know how many elements I should write in the set of three parameters?
How do I write the elements. Should I write the first element from the first set, then the first element from the second set, then the first element from the third set, in order?

I wrote the schedule group like this

set scheduling :=                
(Calculus_II,sunday,8-10) (Calculus_II,monday,12-2) (Calculus_II,wednesday,10-12)
(Applied_Mathematics,sunday,10-12) (Applied_Mathematics,monday,8-10) (Applied_Mathematics,wednesday,10-12);

Can you give me some hints and corrections in the work I have done
I need guidance in scheduling work
Please can you explain that and help me with it

Thanks for all your advice

best wishes.
7.PNG
6.PNG

AMPL Google Group

unread,
May 28, 2021, 3:47:05 PM5/28/21
to AMPL Modeling Language
If the times are the same on every day, then it makes sense to have a set "days" and also a set "time".

"set scheduling within {courses,days,time};" means that scheduling is a set of triples that is contained within the set {courses,days,time}. Another way to say this is that scheduling is a set of triples (i,j,k) where i is a member of courses, j is a member of days, and k is a member of time.

Your data for "scheduling" looks right. If you are not sure about something like this, write a little test like in the attached file, and use a command like "include scheduling.run" to see if it works.


--
Robert Fourer
am...@googlegroups.com
{#HS:1509205583-104221#}
On Wed, May 26, 2021 at 8:01 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
hello Mr. Robert Fourer

On Mon, May 24, 2021 at 1:31 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Chapter 9 of the AMPL book explains the different ways of writing data for a parameter indexed over 3 sets, with examples. See in particular the sections on "Lists of higher-dimensional sets and parameters" (page 148) and "Higher-dimensional tables" (page 157).

Your time set could contain, for example, "Monday1000", "Monday1130", "Monday1300", "Tuesday1030", "Tuesday1300", etc. -- so that each member represents a particular day at a particular time. Then you only need to add one set to your indexing.

Or, if the times are the same every day, you could have a separate time set ("1000", "1130", "1300", etc.) and day set ("Monday", Tuesday", etc.) and add both the time and day sets to your indexing, as in "param capacity {i in door, t in time, d in day} >= 0;".


--
Robert Fourer
am...@googlegroups.com
scheduling.run
Reply all
Reply to author
Forward
0 new messages