Equivalent of "glpsol" in GLPK API - c++

I was wondering if there is an equivalent in GLPK Api of the command line function "glpsol".
Because I have a model which is written in a .mod file and data in .dat file.
In command line I can solve it by calling this line :
glpsol --model flow-glpk.mod --data your_data_set.dat
I would like to solve the same problem in a C/C++ program without execute an "execv()" call.

Have a look at mplsamp2.c in the examples directory of the source distribution, I believe it does what you want, you just have to change the hardcoded names appropriately to your application.
GLPK comes with a nice manual, 3.2 Routines for processing MathProg models details how to deal with MathProg models using the C API.

Related

Including a C++ executable when freezing a Python script with PyInstaller

I've tried to read through the PyInstaller documentation and using spec files, as well as Google/SO, but haven't found any clear answers.
I have written a python script using Biopython, and have made it into an executable with PyInstaller and it works fine. However the script uses a Biopython function (NcbiBlastnCommandline()) that is a wrapper for the NCBI Blast+ blastn program (written in C++), and at the moment the user still needs to have the NCBI Blast+ installed locally.
Is it possible to package the C++ .exe along with the rest, so the end user only needs to download my executable and nothing else?
Read the part of the tutorial about adding binary files:
To add binary files, make a list of tuples that describe the files needed. Assign the list of tuples to the binaries= argument of Analysis.
a = Analysis(...
binaries=[ ( '/path/to/blastn.exe', 'blastn.exe' ) ],
...

How to use snopt libraries?

My situation: I want to use the SNOPT-Solver in Python through pyomo's SolverFactory. I applied for getting the C/C++ libraries for the optimization solver SNOPT and got
libsnopt7.dylib
libsnopt7_cpp.dylib.
After managing to put together a dummy executable which SolverFactory can call, it gives me following error message:
IOError: [Errno 2] No such file or directory:
'/var/folders/_d/vnct15hn3.9j8dhgqr6gjf3rw0000gn/T/tmpoSB0fh.pyomo.sol'
Nevertheless, there is a file with that name, only with a .nl suffix.
Does anyone know why this problem appears and how to solve it?
Thanks a lot.
Pyomo does not have a specialized or library-mode binding to SNOPT. To use SNOPT from Pyomo, you will need a compiled executable called "snopt" that has been built against the ASL (AMPL Solver Library interface). The ASL provides the interface that can read the .nl input file that Pyomo generates and will produce the .sol solution file that Pyomo expects.
You can get the source for the AMPL Solver Library interface, along with the wrapper for SNOPT through Netlib: http://www.netlib.org/ampl/solvers/.

Why does this script not work if the file has a .py extension?

I'm following the instructions in the Coinbase API guide Coinbase Guide The first line of the code is to simply load the Coinbase library:
from coinbase.wallet.client import Client
I'm using IDLE as the IDE. If I work on a file with no extension (e.g. simply called 'coinbase') then the examples in the guide work fine.
If I work on a file with the standard Python extension (e.g. 'coinbase.py') it does not load the Coinbase library and errors out! The error message is:
ImportError: No module named wallet.client
I think this may not necessarily Coinbase related, and perhaps I'm doing something fundamentally wrong. Answers appreciated.
Remember that all python files are seen by python as modules.
So when you write a script called coinbase.py, python will see it as a module and let you import it with import coinbase. Doing so you are shadowing the real coinbase module that you meant to import, hence the error.
To fix the problem simply avoid calling your files with existing module names (unless of course you intend to shadow them).

attempted relative import in non-package error in mavlink

I've already looked through the forums, but I haven't found an answer that is mavlink specific.
I am currently writing script in python, and I want to use a python module of mavlink.
The documentation for mavlink tells me to run mavgenerate.py from my mavlink folder. When I run this script, a gui appears asking for my xml files, a specified output directory, and what language I want my headers in. mavgenerate.py works when I choose to make headers for C, but it gives me the error: "attempted relative import in non-package" when I try to choose python.
my xml files is located at:
C:\Python27\mavlink\message_definitions\v1.0
and I have my python module output directory as:
C:\Python27\mavlink\pymavlink\include
below is a screenshot of my error.
can anyone tell me what I'm doing wrong?
This is quite an old question but i have just encountered with this problem. Solution that i have applied is: in mavgenerate.py replace following lines
sys.path.append(os.path.join('pymavlink','generator'))
from mavgen import *
with
from pymavlink.generator.mavgen import *
I dont know the exact reason of the problem but from
this thread i assume problem lies with python's interpretation of directories as packages.
I have used python 2.7. Tried though to do with python 3.4 but didn't had chance there.

oracle integration repository package

I am new to Oracle and have been having trouble following instructions for importing a package into the integration repository.
The instructions include code for creating a package and body, but don't really tell me what to do with that code. It looks like I should run it in SQL Plus. Is that correct?
It also includes instructions for generating the ILDT file--but only in a generic way. Those instructions just refer me to the "SOA Gateway Implementation Guide". (http://docs.oracle.com/cd/E18727_01/doc.121/e12169/T511175T543269.htm) The command is:
$IAS_ORACLE_HOME/perl/bin/perl $FND_TOP/bin/irep_parser.pl -g -v -username=sysadmin itg:patch/115/sql:fndav.pls:12.0=/tmp/fndav.pls
I'm not sure what to use for the .pls file. Is that generated and then the ILDT file is also created?
Apologies for this newbie question.
I appreciate any help!
Thanks,
Sami
You probably figured this by now, as per oracle conventions .pls file is the package specification and .plb is for package body.