<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Jack:<br>
<br>
I have successfully done this using XFunction, which is now free.<br>
<br>
You need to use CoinMP and build a dll, but it does work.<br>
<br>
The calling code looks like this:<br>
<br>
xFunction create =<br>
new xFunction("CoinMP", "int*
CoinCreateProblem(CSTRING)");<br>
xFunction load =<br>
new xFunction(<br>
"CoinMP",<br>
"int CoinLoadProblem(int*, int, int,"<br>
+ "int,int,int, double*,double*,double*,char*,
int*,int*,int*,"<br>
+ "double*, double*,double*, double*,CSTRING*,
CSTRING*)");<br>
xFunction optimize =<br>
new xFunction("CoinMP", "int
CoinOptimizeProblem(int*,int)");<br>
xFunction getsol =<br>
new xFunction(<br>
"CoinMP",<br>
"int CoinGetSolutionValues(int*, double*,
double*,double*,double*)");<br>
xFunction writemps =<br>
new xFunction(<br>
"CoinMP",<br>
"int CoinWriteFile(int*, int, CSTRING)");<br>
xFunction openlog =<br>
new xFunction("CoinMP", "int
CoinOpenLogFile(int*,CSTRING)");<br>
xFunction closelog =<br>
new xFunction("CoinMP", "int
CoinCloseLogFile(int*)");<br>
xFunction getstatus =<br>
new xFunction("CoinMP", "int
CoinGetSolutionStatus(int*)");<br>
xFunction getstatustext =<br>
new xFunction(<br>
"CoinMP",<br>
"CSTRING CoinGetSolutionText(int*,int)");<br>
xFunction setintstatus =<br>
new xFunction("CoinMP", "int CoinSetIntOption(int*,
int,int)");<br>
xFunction getobjvalue =<br>
new xFunction("CoinMP", "double
CoinGetObjectValue(int*)");<br>
xFunction getiterations =<br>
new xFunction("CoinMP", "int
CoinGetIterCount(int*)");<br>
xFunction unloadproblem =<br>
new xFunction("CoinMP", "int
CoinUnloadProblem(int*)");<br>
<br>
intgrp = 0;<br>
<br>
int numrows = lpproblem.getRows().size();<br>
int numcols = lpproblem.getCols().size();<br>
int numel = lpproblem.getAmatrix().size();<br>
<br>
double[] objcoeff = new double[numcols];<br>
double[] matval = new double[numel]; // the non-zero
values in the matrix<br>
int[] matbeg = new int[numcols + 1]; // the starting
values in the matval array for each variable<br>
int[] matsize = new int[numcols]; // the starting values
in the matval array for each variable<br>
int[] matind = new int[numel]; // these values indicate
in which row each matval element appears<br>
double[] ub = new double[numcols];<br>
double[] lb = new double[numcols];<br>
double[] initval = new double[numcols];<br>
String[] colnames = new String[numcols];<br>
<br>
int iel = 0;<br>
<br>
for (int i = 0; i < numcols; i++) {<br>
LPCol col = lpproblem.getCols().get(i);<br>
ub[i] = col.getColmax();<br>
lb[i] = col.getColmin();<br>
initval[i] = lb[i];<br>
objcoeff[i] = col.getFobj();<br>
colnames[i] = col.getColnames();<br>
<br>
<br>
int iax = col.getMcol();<br>
matbeg[i] = iel;<br>
<br>
for (int j = 0; j < col.getMent(); j++) {<br>
LPMat mat = lpproblem.getAmatrix().get(iax);<br>
matval[iel] = mat.getAmat();<br>
matind[iel++] = mat.getMrow();<br>
iax = mat.getNext();<br>
}<br>
}<br>
<br>
matbeg[numcols] = iel;<br>
<br>
double[] rhsval = new double[numrows];<br>
double[] rngval = new double[numrows];<br>
String[] rowname = new String[numrows];<br>
char[] senx = new char[numrows];<br>
<br>
for (int i = 0; i < numrows; i++) {<br>
LPRow row = lpproblem.getRows().get(i);<br>
<br>
if (!row.getSenx().equals("R")) {<br>
rhsval[i] = row.getRhsx();<br>
rngval[i] = row.getRngval();<br>
} else {<br>
rhsval[i] = row.getRhsx() + row.getRngval();<br>
rngval[i] = row.getRngval();<br>
}<br>
<br>
rowname[i] = row.getRownames();<br>
senx[i] = row.getSenx().charAt(0);<br>
}<br>
<br>
//<br>
// Initialize the CLP library<br>
//<br>
Argument arg1 = new Argument("Promax Problem",
Argument.CSTRING);<br>
System.out.println(" calling create ");<br>
<br>
Pointer hprob = (Pointer) create.invoke(arg1);<br>
/*<br>
CallBackFunc func = new CallBackFunc();<br>
int msgresult =<br>
((Integer) setmsgcallback.invoke(hprob, new
Argument(func)))<br>
.intValue();<br>
System.out.println(" open message result " + msgresult);<br>
*/<br>
System.out.println(" returned pointer " + hprob);<br>
<br>
Argument[] args = new Argument[19];<br>
args[0] = hprob;<br>
args[1] = new Argument(numcols);<br>
args[2] = new Argument(numrows);<br>
args[3] = new Argument(numel);<br>
args[4] = new Argument(numrows);<br>
args[5] = new Argument(-1);<br>
args[6] = (Pointer) Argument.create("double*",
objcoeff);<br>
args[7] = (Pointer) Argument.create("double*", rhsval);<br>
args[8] = (Pointer) Argument.create("double*", rngval);<br>
args[9] = (Pointer) Argument.create("char*", senx);<br>
args[10] = (Pointer) Argument.create("int*", matbeg);<br>
args[11] = (Pointer) Argument.create("int*", matsize);<br>
args[12] = (Pointer) Argument.create("int*", matind);<br>
args[13] = (Pointer) Argument.create("double*", matval);<br>
args[14] = (Pointer) Argument.create("double*", lb);<br>
args[15] = (Pointer) Argument.create("double*", ub);<br>
args[16] = (Pointer) Argument.create("double*",
initval);<br>
args[17] = (Pointer) Argument.create("CSTRING*",
colnames);<br>
args[18] = (Pointer) Argument.create("CSTRING*",
rowname);<br>
System.out.println(" calling load ");<br>
<br>
int loadresult = ((Integer)
load.invoke(args)).intValue();<br>
System.out.println(" load result " + loadresult);<br>
<br>
/*<br>
Argument arg3 = new Argument("c:\\css.mps",
Argument.CSTRING);<br>
System.out.println(" writing mps ");<br>
int mpsresult =<br>
((Integer) writemps.invoke(hprob, new
Argument(1), arg3))<br>
.intValue();<br>
System.out.println(" writing mps result " +
mpsresult);<br>
*/<br>
System.out.println(" calling optimize ");<br>
<br>
int optresult =<br>
((Integer) optimize.invoke(hprob, new
Argument(0))).intValue();<br>
System.out.println(" optimize result " + loadresult);<br>
<br>
int solutionstatus = ((Integer)
getstatus.invoke(hprob)).intValue();<br>
<br>
System.out.println(" solution status " +
solutionstatus);<br>
<br>
String solutionstatustext =<br>
(String) getstatustext.invoke(<br>
hprob,<br>
new Argument(solutionstatus));<br>
int iterations = ((Integer)
getiterations.invoke(hprob)).intValue();<br>
double obj = ((Double)
getobjvalue.invoke(hprob)).doubleValue();<br>
System.out.println(" solution status text " +
solutionstatustext);<br>
<br>
<br>
<div class="moz-cite-prefix">On 8/04/2013 12:29 AM, Jack Hagart
wrote:<br>
</div>
<blockquote
cite="mid:CANztv9raMW9DZZcace6kyTMBgaSLTO0iZSq75uz7EF9ZsC-9qQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hello friends of CLP mail-list,<br>
<br>
</div>
I´m developing an optmization software using
CLP. I have a mathematical model to describe the
real world problem and a GUI in java.<br>
<br>
</div>
The users input their data in the visual interface
and the GUI will write the problem in .lp file
format, call the CLP.exe by command line, get the
output solution and plot in the visual inteface to
the user.<br>
<br>
It works very well, to a professional aplication!
Thanks to the developers of CLP.<br>
<br>
</div>
My question is. I would like that my commercial
software wouldn´t very easy to make a copy by
someone, and then, they do their implementation and
sell another software that do exactly what mine do.<br>
<br>
</div>
I would like to input the mathematical model in CLP
without use a .lp file (which could be intercepted and
the mathematical model reproduced).<br>
<br>
</div>
Please, someone know how can I do this?<br>
<br>
</div>
One idea was integrate the java GUI with a java solver,
but I didn´t find a Java version of CLP or other linear
solvers.<br>
<br>
</div>
Another idea was to develop the input in C (what I did) but
I wasn´t able to understande how to integrate my input
information of the user with the CLP whitout using a .lp
file.<br>
<br>
</div>
If someaone have a idea, please, tell me.<br>
<br>
</div>
Best Regards,<br>
Jack Hagart<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Clp mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Clp@list.coin-or.org">Clp@list.coin-or.org</a>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/clp">http://list.coin-or.org/mailman/listinfo/clp</a>
</pre>
</blockquote>
<br>
</body>
</html>