Getting a table out of a GLPK solution throws error "Assertion failed: out != out" - glpk

I have a linear program in a file lp that GLPK solves with this command:
glpsol --math -m lp
Part of the output on the screen is:
Generating priority_words...
Model has been successfully generated
...
Long-step dual simplex will be used
+ 770: mip = not found yet <= +inf (1; 0)
Solution found by heuristic: 1569225
...
INTEGER OPTIMAL SOLUTION FOUND
...
Writing MIP solution to 'result'...
The file result is unformatted and I want to save the results in CSV. So I include a line to output the results to a table right after the last constraint and before the end; keyword:
...
s.t. priority_words{w in words}: include[w] >= priority[w];
table num{u in unicodes} OUT "CSV" "num.csv": u~unicode, number_of_characters[u]~count;
end;
And GLPK gives this error:
Generating priority_words...
Writing num...
Assertion failed: out != out
Error detected in file mpl/mpl3.c at line 5072
Abort trap: 6
Neither the wikibook nor the gmpl manual in the distribution (at doc/gmpl.pdf) have an example of getting a table out of GLPK.
How can I ask GLPK for a table of results after solving the model?

Note that the output for the code with the table OUT statement does not have the line Model has been successfully generated. Therefore GLPK attempted to write the table of results before solving the problem! The sample code in this thread shows that GLPK needs to know when to solve the problem, otherwise it solves it at the end. So just add solve; before the table:
...
s.t. priority_words{w in words}: include[w] >= priority[w];
solve;
table num{u in unicodes} OUT "CSV" "num.csv": u~unicode, number_of_characters[u]~count;
end;

Neither the wikibook nor the gmpl manual in the distribution (at doc/gmpl.pdf) have an example of getting a table out of GLPK.
The current version of GLPK is 4.65. The lines below relate to this version.
Examples are in:
examples/csv
examples/sql
examples/dbf
doc/gmpl.pdf has a chapter on the table statement.

Related

How to analyze a MariaDB crash log?

When I created a partition for an existing table, I got an exception stack below:
Thread pointer: 0x1ce1ecc6ab8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
mysqld.exe!ha_partition::read_par_file()[ha_partition.cc:3021]
mysqld.exe!ha_partition::get_from_handler_file()[ha_partition.cc:3161]
mysqld.exe!ha_partition::initialize_partition()[ha_partition.cc:512]
mysqld.exe!partition_create_handler()[ha_partition.cc:185]
mysqld.exe!get_new_handler()[handler.cc:302]
mysqld.exe!TABLE_SHARE::init_from_binary_frm_image()[table.cc:2025]
mysqld.exe!open_table_def()[table.cc:698]
mysqld.exe!tdc_acquire_share()[table_cache.cc:842]
mysqld.exe!open_table()[sql_base.cc:1905]
mysqld.exe!open_and_process_table()[sql_base.cc:3802]
mysqld.exe!open_tables()[sql_base.cc:4300]
mysqld.exe!mysql_alter_table()[sql_table.cc:9353]
mysqld.exe!Sql_cmd_alter_table::execute()[sql_alter.cc:510]
mysqld.exe!mysql_execute_command()[sql_parse.cc:6087]
mysqld.exe!Prepared_statement::execute()[sql_prepare.cc:4760]
mysqld.exe!Prepared_statement::execute_loop()[sql_prepare.cc:4246]
mysqld.exe!mysql_sql_stmt_execute()[sql_prepare.cc:3364]
mysqld.exe!mysql_execute_command()[sql_parse.cc:3901]
mysqld.exe!sp_instr_stmt::exec_core()[sp_head.cc:3652]
mysqld.exe!sp_lex_keeper::reset_lex_and_exec_core()[sp_head.cc:3335]
mysqld.exe!sp_instr_stmt::execute()[sp_head.cc:3513]
mysqld.exe!sp_head::execute()[sp_head.cc:1346]
mysqld.exe!sp_head::execute_procedure()[sp_head.cc:2288]
mysqld.exe!do_execute_sp()[sql_parse.cc:3005]
mysqld.exe!Sql_cmd_call::execute()[sql_parse.cc:3247]
mysqld.exe!mysql_execute_command()[sql_parse.cc:6087]
mysqld.exe!sp_instr_stmt::exec_core()[sp_head.cc:3652]
mysqld.exe!sp_lex_keeper::reset_lex_and_exec_core()[sp_head.cc:3335]
mysqld.exe!sp_instr_stmt::execute()[sp_head.cc:3513]
mysqld.exe!sp_head::execute()[sp_head.cc:1346]
mysqld.exe!sp_head::execute_procedure()[sp_head.cc:2288]
mysqld.exe!Event_job_data::execute()[event_data_objects.cc:1459]
mysqld.exe!Event_worker_thread::run()[event_scheduler.cc:312]
mysqld.exe!event_worker_thread()[event_scheduler.cc:268]
mysqld.exe!pthread_start()[my_winthread.c:62]
ucrtbase.dll!_configthreadlocale()
KERNEL32.DLL!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x1ce21cf66b8): alter table mytable add PARTITION (PARTITION t20221103 VALUES LESS THAN (TO_DAYS("2022-11-03")+1))
Connection ID (thread ID): 1649
Status: NOT_KILLED
The running platform is windows so I cannot debug the core file.
Therefore, I read the source code but I cannot understand the reason still deeply.
The database version is 10.4.6 so here is the source code link:
https://github.com/MariaDB/server/blob/mariadb-10.4.6/sql/ha_partition.cc#L3021
chksum= 0;
for (i= 0; i < len_words; i++)
chksum ^= uint4korr((file_buffer) + PAR_WORD_SIZE * i);
if (chksum)
goto err2;
m_tot_parts= uint4korr((file_buffer) + PAR_NUM_PARTS_OFFSET);
DBUG_PRINT("info", ("No of parts: %u", m_tot_parts));
tot_partition_words= (m_tot_parts + PAR_WORD_SIZE - 1) / PAR_WORD_SIZE;
tot_name_len_offset= file_buffer + PAR_ENGINES_OFFSET +
PAR_WORD_SIZE * tot_partition_words;
tot_name_words= (uint4korr(tot_name_len_offset) + PAR_WORD_SIZE - 1) /
PAR_WORD_SIZE; // <--- crashed here
There are some macros, so I don't know whether the line number is exact.
It seems a bug for loading the par file. I found that the above code has checked the validation on the par file, but subsequently, MariaDB still raises the exception.
So, I wonder if my analysis is right and how to bypass the exception, thanks a lot.
First is to search existing bug reports for 'read_par_file', and there's no obvious match.
Second is, looking at the line it crashed, we can assume its reading from memory that isn't allocated. The file_buffer was allocated earlier in the file based of a word length at the beginning.
Third, if you look at the git blame of the function, you see nothing has changed in quite a while.
So its likely a new bug. Please report it using the show create table and par file.
To confirm, that the show create table mytable, paste that into a running 10.4 latest version (containers are good for this). Then issue your alter table statement again. Its likely to crash, but its good to confirm.
There does seem to be a lack of checking around some of these offsets with regard to the allocated space.
Given it looks like you are doing daily partitions, have you exceeded the maximum partitions of 8k per table? Either way, an error message should occur rather than a crash.

Why can't I open a *.w file in the appBuilder?

I have a *.w file, referring to two include files ({incl\include_file.i}, {incl\do_something_file.i}). That first include-file contains the definition of a RECID variable "recordid":
DEF INPUT-OUTPUT PARAMETER recordid AS RECID.
I am capable to compile the *.w file, the listing file looks as follows: (just a fragment)
Prompt>findstr "recordid do_something" listing.txt
...
1 x DEF INPUT-OUTPUT PARAMETER recordid AS RECID.
...
1 x 1 {incl\do_something_file.i
2 x 1 INPUT-OUTPUT recordid
So, the compilation works. In top of that, I've checked the pairs of "&ANALYZE-SUSPEND" and "&ANALYZE-RESUME" clauses and everything is fine.
Nevertheless, I can't open the *.w file, as the mentioned RECID seems not to be known (errors 201 and 196).
Edit after first comments
This the exact error message I get while opening the *.w file, using the AppBuilder (I'm working with a Dutch version of the tool, hence the Dutch words in between):
---------------------------
Fout
---------------------------
This file cannot be analyzed by the AppBuilder.
Please check these problems in your file or environment:
** Onbekende veld- of variabelenaam - recordid. (201)
** .\incl\<do_something_file>.i Compilatiefout op regel 7. (196)
---------------------------
OK
---------------------------
Edit with more information on ANALYZE- clauses
I've launched following findstr command on my code with the following results:
Prompt>findstr /I "ANALYZE-RESUME ANALYZE-SUSPEND" <filename>.w
&ANALYZE-SUSPEND _VERSION-NUMBER ... GUI
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS ...
&ANALYZE-RESUME
...
I confirm that the number of &ANALYZE-SUSPEND clauses equals the number of &ANALYZE-RESUME clauses, they are in the right sequence (first a SUSPEND and then a RESUME) and none of them is commented out.
Does anybody have an idea what's going wrong?
The problem was caused by an include, being outside of an suspend resume clause, in order to solve such a situation the following command might be useful:
findstr /I "ANALYZE {incl" <source_file>.w
The result should look like the following:
...
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win
{incl\something.i}
{incl\something_else.i}
&ANALYZE-RESUME
...
You see following rules:
The number of suspends and resumes must be equal.
Every suspend is to be closed by a resume.
Not one of those can be commented out.
It is advised to have includes between the suspend and the resume.

Create table in multiple databases with flyway

I'm trying to connect to the multiple databases and create tables, but when migrating flyway gets syntax error.
This is the migration file I'm trying to run:
\c testdatabase;
CREATE TABLE testtable1;
\c testdatabase2;
CREATE TABLE testtable2;
Flyway gives this output:
Error Code : 0
Message : ERROR: syntax error at or near "\"
Position: 1
Line : 1
Statement : \c testdatabase
It seems like flyway does not support meta-commands like "\c" for connecting to the database. Is there any other way to do connect to the databases and create a table?
The error comes (as indicated in the error input) from the comment lines preceding your two SQL statements in the script: \c testdatabase; which are not valid SQL syntax for comments.
You could simply correct those faulty lines like the following: -- testdatabase, and generally, the error input already gives you a hint as to where lies the problem.

Sqlite (within SqliteStudio): invalid command name "parray"

I am discovering writing functions in TCL for Sqlite (https://github.com/pawelsalawa/sqlitestudio/wiki/ScriptingTcl).
I wanted to play a basic exemple found in the official page of sqlite(http://sqlite.org/tclsqlite.html):
db eval {SELECT * FROM MyTable ORDER BY MyID} values {
parray values
puts ""
}
I get the following error:
Error while requesting the database « -- » : invalid command name "parray"
Help is very welcome :)
SqliteStudio does not seem to fully initialise Tcl, as you would expect it from a non-embedded installation:
Using external Tcl packages or modules is not possible, because Tcl
interpreters are not initialized with "init.tcl".
See Wiki.
Background
Standard Tcl sources init.tcl, early as part of an Tcl interpreter's initialisation. init.tcl, in turn, registers a number of Tcl procs for autoloading. parray is one of those lazily acquired procs.
Ways forward
I am not familiar with SqliteStudio. Why not stick with sqlite's standard Tcl frontend, which gives you full Tcl and comes with Tcl distributions free house? But this certainly depends on your requirements.
That said, you could attempt to force-load init.tcl in SqliteStudio's embedded Tcl, but I don't know (and can't test) whether the distribution has not pruned these scripts or whether they were effectively relocated. From the top of my head (untested):
source [file join $tcl_library init.tcl]
# ...
db eval {SELECT * FROM MyTable ORDER BY MyID} values {
parray values
puts ""
}

glm probit "cannot find valid starting values" error message

I am trying to use R for the first time to do some probit analaysis.
I get the following error:
Error in if (!(validmu(mu) && valideta(eta))) stop("cannot find valid starting values: please specify some", :
missing value where TRUE/FALSE needed
This is the command I am using:
m1=glm(Good~Stg.Days+Dev.Deployments+Check.Ins+NoOfDevelopers,family=poisson(link = "probit"),data=deploy[1:4,])
My data deploy[1:4,] are as loaded in from a CSV file follows:
Good,Application Type,Project,Start Date,End Date,Stg Days,Dev Deployments,Check Ins,NoOfDevelopers
1,DocumentPlatform,ZCP,11/08/2010,11/11/2010,0.6,0,12,4
1,DocumentPlatform,ZCP,11/11/2010,09/12/2010,0.4,0,4,1
0,DocumentPlatform,ZCP,09/12/2010,07/03/2011,10,0,7,3
1,FactsheetPlatform,Process.ARCH,28/06/2010,09/03/2011,7.1,0,18,2
deploy is in reality a much bigger vector than 1:4 I am just using a subset of the data to help determine the problem.
Any ideas what is wrong?
As i commented: Using ?glm I found tha the poisoon family supports the following links: log, identity, and sqrt.
Testing on another link:
test <- data.frame('Good'=c(1,1,0,1),'Stg Days'=c(0.6,0.4,10,7.1),'Dev Deployments'=c(0,0,0,0),'Check Ins'=c(12,4,7,18),'NoOfDevelopers'=c(4,1,3,2))
m1=glm(Good~ . ,family=poisson(link = "log"),data=test)
Gives no errors. So I think your link = "probit" is the problem.

Resources