help me set up a model

Problems with modeling
Post Reply
Ildar
User
User
Posts: 8
Joined: 5 years ago

help me set up a model

Post by Ildar »

Hi all
Sorry for my english
help please set up Gams, to quickly decide my test

my model

Code: Select all

Scalar m;
m=smax((i,j,r), w(i)*k(i,j,r) / uc(i));

binary Variables
x(j,r);

positive variables
z(i,j,r),a(i);

Free variables
opt;

Equations
goal
upperZ(i,j,r)
lowerZ(i,j,r)
less(i,j,r)
budget
omg(i)
ogrp;
goal.. opt=e=sum(i,sum(j,sum(r,z(i,j,r))));
upperZ(i,j,r).. z(i,j,r)=l=k(i,j,r)*a(i);
lowerZ(i,j,r).. k(i,j,r)*a(i)+m*(x(j,r)-1)=l=z(i,j,r);
less(i,j,r).. z(i,j,r)=l=x(j,r)*w(i);
budget.. sum((j,r),c(j,r)*x(j,r))=l=b;
omg(i).. sum((j,r),z(i,j,r))+a(i)*uc(i)=e=w(i);
ogrp.. sum((j,r),x(j,r))=e=p;
model Shops
/goal,
upperZ,
lowerZ,
less,
budget,
omg,
ogrp/;

option ResLim = 7200;
Solve Shops using MIP max opt;
variables are read from a file of the form

Code: Select all

Sets
i
/
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
/
j(i)
/
4,
10
/
r
/
1,
2,
3
/;
Parameter w(i)
/
1 = 1
2 = 6
3 = 8
4 = 7
5 = 1
6 = 8
7 = 4
8 = 8
9 = 10
10 = 9
/;
Parameter c(j,r)
/
10.1 = 1
10.2 = 2
10.3 = 3
4.1 = 1
4.2 = 2
4.3 = 3
/;

Parameter k(i,j,r)
/
1.10.1 = 0.03
1.10.2 = 0.05
1.10.3 = 0.12
1.4.1 = 0.0117
1.4.2 = 0.0273
1.4.3 = 0.043
2.10.1 = 0.00357
2.10.2 = 0.00595
2.10.3 = 0.0143
2.4.1 = 0.00357
2.4.2 = 0.00832
2.4.3 = 0.0131
3.10.1 = 0.0612
3.10.2 = 0.102
3.10.3 = 0.245
3.4.1 = 0.0612
3.4.2 = 0.143
3.4.3 = 0.224
4.10.1 = 0.0075
4.10.2 = 0.0125
4.10.3 = 0.03
4.4.1 = 3.0
4.4.2 = 7.0
4.4.3 = 11.0
5.10.1 = 0.0133
5.10.2 = 0.0222
5.10.3 = 0.0533
5.4.1 = 0.0248
5.4.2 = 0.0579
5.4.3 = 0.0909
6.10.1 = 0.0178
6.10.2 = 0.0296
6.10.3 = 0.071
6.4.1 = 0.037
6.4.2 = 0.0864
6.4.3 = 0.136
7.10.1 = 0.00444
7.10.2 = 0.0074
7.10.3 = 0.0178
7.4.1 = 0.00275
7.4.2 = 0.00643
7.4.3 = 0.0101
8.10.1 = 0.0833
8.10.2 = 0.139
8.10.3 = 0.333
8.4.1 = 0.00275
8.4.2 = 0.00643
8.4.3 = 0.0101
9.10.1 = 0.037
9.10.2 = 0.0617
9.10.3 = 0.148
9.4.1 = 0.0248
9.4.2 = 0.0579
9.4.3 = 0.0909
10.10.1 = 3.0
10.10.2 = 5.0
10.10.3 = 12.0
10.4.1 = 0.0075
10.4.2 = 0.0175
10.4.3 = 0.0275
/;

Parameter uc(i)
/
1 = 3.48
2 = 3.32
3 = 7.41
4 = 0.312
5 = 8.37
6 = 3.35
7 = 18.3
8 = 10.7
9 = 3.16
10 = 0.571
/;
Scalar b / 20 /;
Scalar p / 10 /;
with large variables i>200 p>100 starts counting for a very long time

I have limited time but this does not always reach even relaxation
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: help me set up a model

Post by bussieck »

Perhaps you can attach (not copy&paste into the topic) the instance that takes a long time. In this you might generate lots of variables that are 0 anyway.

-Michael
Ildar
User
User
Posts: 8
Joined: 5 years ago

Re: help me set up a model

Post by Ildar »

attached model and test file

I run through .bat
"C:\GAMS23.3\gams.exe" "C:\test\gamsLP" --filename=gams.200.37.25.1.gms MIP=cplex lo=2 lf=200.37.25.1.log
Attachments
gams.200.37.25.1.gms
testfile
(993.82 KiB) Downloaded 182 times
gamsLP.gms
Model
(1010 Bytes) Downloaded 193 times
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: help me set up a model

Post by bussieck »

GAMS generates the model quickly but the solver has a hard time proving optimality. This is a MIP and they can be difficult. I have attached the log of a run with Gurobi. Cplex and Xpress behave similarly. The LP is already difficult. I added option "option threads=4;" so the solver can use concurrent LP to select the best algorithm.

-Michael
Attachments
gamsLP.log
(6.48 KiB) Downloaded 193 times
Ildar
User
User
Posts: 8
Joined: 5 years ago

Re: help me set up a model

Post by Ildar »

where to add threads = 4;? because he gives me an error
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: help me set up a model

Post by bussieck »

You can add the thread option (https://www.gams.com/latest/docs/UG_Gam ... SAOthreads) in different ways: I can't believe you missed them all while carefully studying the documentation.

-Michael
Ildar
User
User
Posts: 8
Joined: 5 years ago

Re: help me set up a model

Post by Ildar »

Thank
Can I somehow speed up the algorithm? I only need to calculate the top scores.

Please tell us a little about the output file. I beg you to calmly take this because I'm just starting to study)

How can I work with a branch tree? cut like the depth and width of the tree?
Since a valid solution is found quickly enough, not always, but nothing can be done with it. But when the relaxation process begins the trees are very large.
Attachments
200.15.10.1.log
(55.19 KiB) Downloaded 183 times
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: help me set up a model

Post by bussieck »

If I knew how to do this I would be raking in money by selling superior MIP solvers. You need to invest to learn about optimization and see if you can do something smart for your particular situation/model. There are no shortcuts.

-Michael
Ildar
User
User
Posts: 8
Joined: 5 years ago

Re: help me set up a model

Post by Ildar »

You did not understand me correctly, I do not need to find an exact solution.
Since this upper estimates will go and approximate

Finding a feasible solution we cannot limit; we would like to limit the work of branches and borders

The main thing that would be solved in a reasonable time and not in days, since there are more than 1000 test problems

I have limited Shops.NodLim = 150; but did not understand how to work with ModelName.Cheat = x or ModelName.Cutoff = x
Attachments
gamsLP.gms
(1.07 KiB) Downloaded 180 times
gams.200.75.50.1.gms
(1.19 MiB) Downloaded 184 times
200.75.50.3.log
(32.57 KiB) Downloaded 179 times
Post Reply