Forum Discussion
FICO
1 year agoCommunity Manager
Error 11 when writing results to a database.
I am trying to insert results into a sqlite database using the following:
SQLexecute("
INSERT INTO res_rm_markets_oper
(case_id, market, strat_node, oper_scenario, oper_period, bid_up, bid_down)
VALUES (" + caseID + ",?,?,?,?,?,?)",
[array(rm in RM_MARKETS, sn in ST_N, osc in SN_OP_SCENS(sn), op in O_PERS(osc)) rm_bid_up(rm,sn,osc,op).sol,
array(rm in RM_MARKETS, sn in ST_N, osc in SN_OP_SCENS(sn), op in O_PERS(osc)) rm_bid_down(rm,sn,osc,op).sol])This fails with the following error message:
ODBC: Inconsistent array list.
Mosel: Error located at line 452 of `XXX.mos'.
ERROR input parsing returned error code 11! I don't understand what "inconsistent" means here. Both `rm_bid_up` and `rm_bid_down` are dynamic arrays defined on the same sets.
Moreover, the command fails even if I use the same variable on both lines, so the arrays are equal.
It works with only one variable (and one question mark replaced by a number) - both for the first and the second variable.
I have also tried filtering the array using `exists()`, but it does not help.
The weird thing is that we have many such commands in the model from before and I do not see how this one differs from the others.
Any idea what is going on, or how can I debug this?
2 Replies
- FICOCommunity Manager
The indexing sets of the two arrays that are used in the SQL statement are not entirely the same: when processing the following definition:
array(rm in RM_MARKETS, sn in ST_N, osc in SN_OP_SCENS(sn), op in O_PERS(osc))
the compiler will generate new sets for each of the 2 last indices, resulting in something like:
array(RM_MARKETS, ST_N, set of integer, set of integer)
such that they are not identical for the two arrays (even if in the end they have the same content).
A way of avoiding the issue could be to use globally defined sets for these indices and rely on a condition to select the requested values:
array(rm in RM_MARKETS, sn in ST_N, osc in I, op in J | i in SN_OP_SCENS(sn) and op in O_PERS(osc))
with I and J being the actual indexing sets of the target arrays (rm_bid_up and rm_bid_down). If they are not explicitly defined elsewhere in your model, they could be calculated as
I:= union(sn in ST_N) SN_OP_SCENS(sn)
J:= union(osc in I) O_PERS(osc)
- FICOCommunity Manager
Dear Susanne,
thanks for the answer, your suggestion works. :-)
(And looking at the existing code in the model, all DB-writing code uses global sets, so I must have known this at some point, but did not write it down...)
Related Content
Related Content
How to write to an access database from mosel
I have created an access database and I am trying to connect to and then write to that database. I am working currently in the Workbench. My code is as follows: DBcxn := "mmodbc.odbc:LoadMax.accd...5 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread0Views0likes1CommentWhy Mosel result is not as optimal as Gams result?
Hi, I use both Gams and FICO Mosel to solve the same model, but the result from Mosel is not as optimal as the result from Gams. What might cause this difference? 1. It's a MIP problem 2. Set the ...9 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum7 unread comments7 unread0Views0likes7Comments
