Python API - mi.solve

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
silence
User
User
Posts: 14
Joined: 2 years ago

Python API - mi.solve

Post by silence » 5 days ago

Hi everyone,

I’m using Python to call GAMS to solve an MIP problem. There are 6 parameters that need to be updated. When the model was run, the following problem occurred.
2.png
When the parameters "COST" and "WD" were commented out, the model run successfully.
1.png
What should I do about this problem?
Here are the model and input files.

Thanks~
model and input.rar
(9.97 KiB) Downloaded 7 times

User avatar
bussieck
Moderator
Moderator
Posts: 685
Joined: 5 years ago

Re: Python API - mi.solve

Post by bussieck » 4 days ago

The error message "Unmatched record limit exceeded while processing modifier COST, for more info check GamsModelInstanceOpt parameter no_match_limit" is a good start to debug. The default no_match_limit is 0, so all records in the syncDB need a parameter in the model. For COST syncDB contains:

Code: Select all

Parameter COST(*) Cost /
'1' 9900,
'2' 39900,
'3' 0.38,
'4' 1.48,
'5' 0.15,
'6' 0.236,
'7' 0.15,
'8' 0.314,
'9' 0.154 /;
while the model misses COST('2'). You can e.g. use the "solver" convert with option "dict" to see the elements of the model. Please note that the modifiable parameters are turned into variables and get an additional suffix "_var", so for COST we have:

Code: Select all

  x513  COST_var(1)
  x514  COST_var(3)
  x515  COST_var(4)
  x516  COST_var(5)
  x517  COST_var(6)
  x518  COST_var(7)
  x519  COST_var(8)
  x520  COST_var(9)
With symbol WD it is even worse. The syncDB has

Code: Select all

Parameter WD(*,*) Water demand /
'1'.'1' 135.2074323,
'1'.'2' 126.6750235,
'1'.'3' 147.4151586,
'1'.'4' 151.8117234,
'1'.'5' 153.9757086,
'1'.'6' 123.7169225,
'1'.'7' 135.3514663,
'1'.'8' 117.5905595,
'1'.'9' 123.1176089,
'1'.'10' 113.2271104,
'1'.'11' 127.2642251,
'1'.'12' 126.3364306,
'2'.'1' 270.4148646,
'2'.'2' 253.3500469,
...
'8'.'12' 119.6750741,
'9'.'1' 746.2178706,
'9'.'2' 643.8894274,
'9'.'3' 741.9646101,
'9'.'4' 717.8106774,
'9'.'5' 671.2645794,
'9'.'6' 650.1859209,
'9'.'7' 695.4393613,
'9'.'8' 698.5354848,
'9'.'9' 684.96258,
'9'.'10' 715.965513,
'9'.'11' 730.1326232,
'9'.'12' 801.0307224 /;
while the model has

Code: Select all

  x569  WD_var(CXD,1)
  x570  WD_var(CXD,2)
  x571  WD_var(CXD,3)
  x572  WD_var(CXD,4)
  x573  WD_var(CXD,5)
  x574  WD_var(CXD,6)
  x575  WD_var(CXD,7)
  x576  WD_var(CXD,8)
  x577  WD_var(CXD,9)
  x578  WD_var(CXD,10)
  x579  WD_var(CXD,11)
  x580  WD_var(CXD,12)
  x581  WD_var(HLSH,1)
  x582  WD_var(HLSH,2)
  x583  WD_var(HLSH,3)
  x584  WD_var(HLSH,4)
  x585  WD_var(HLSH,5)
  x586  WD_var(HLSH,6)
  x587  WD_var(HLSH,7)
  x588  WD_var(HLSH,8)
  x589  WD_var(HLSH,9)
  x590  WD_var(HLSH,10)
  x591  WD_var(HLSH,11)
  x592  WD_var(HLSH,12)
  x593  WD_var(WFD,1)
  x594  WD_var(WFD,2)
...
  x664  WD_var(ZH,12)
  x665  WD_var(KFQ,1)
  x666  WD_var(KFQ,2)
  x667  WD_var(KFQ,3)
  x668  WD_var(KFQ,4)
  x669  WD_var(KFQ,5)
  x670  WD_var(KFQ,6)
  x671  WD_var(KFQ,7)
  x672  WD_var(KFQ,8)
  x673  WD_var(KFQ,9)
  x674  WD_var(KFQ,10)
  x675  WD_var(KFQ,11)
  x676  WD_var(KFQ,12)
The COST issue you could resolve by increasing no_match_limit, but the WD issue needs to be dealt with properly. Either use 1 to 9 inside GAMS or fill the syncDB with proper customer names.

You need to understand how to debug such issues and I hope I have given you some pointers how to accomplish this.

-Michael

Post Reply