[Cmpl] Suboptimal solution when reading from CSV
Indrajit Sen Gupta
indrajitsg at gmail.com
Mon Nov 24 13:20:03 EST 2014
Awesome. Thanks for clarifying both the issues.
Regards,
Indrajit
On Mon, Nov 24, 2014 at 11:22 PM, Mike Steglich <mike.steglich at th-wildau.de>
wrote:
> Hi Indrjajit,
>
> I analysed your problem with invoking Cplex shipped with the Ampl demo
> version. This Cplex version is customised for Ampl and can't be used with
> Cmpl. If you want to use Cplex then try to receive a normal Cplex version
> directly from IBM's academic initiative. This version works with Cmpl as
> I've described it in one of my last emails before.
>
> I found a bug in readcsv() for reading a vector that is specified as n
> rows with one element in the csv file. I will fix it with the next release.
> In the meantime please specify a vector in a csv file one row with n
> elements. This works properly.
>
> But I would like to suggest to use a cmplData file instead csv files. This
> is Cmpl's standard data format and it is more convenient and more flexible.
>
> Thanks,
>
> Mike
>
>
>
>
>
>
> Am 23.11.2014 um 20:05 schrieb Indrajit Sen Gupta <indrajitsg at gmail.com>:
>
> Hi Mike,
>
> I am trying out one of the examples from the manual (Pg 31):
>
> -------------------------------------------------------------------
> %arg -solver cbc
> %arg -solutionAscii
> parameters:
> # Reading data from CSV
> c[] := readcsv("c.csv");
> b[] := readcsv("b.csv");
> A[,] := readcsv("a.csv");
> # Reading data directly
> # c[] := (1,2,3);
> # b[] := (15,20);
> # A[,] := ((5.6, 7.7, 10.5),
> # (9.8, 4.2, 11.1));
>
> variables:
> x[defset(c[])] : real[0..];
>
> objectives:
> c[]T * x[] -> max;
> constraints:
> A[,] * x[] <= b[];
> -------------------------------------------------------------------
> When I use the readcsv command to read the data, this is the output that I
> get:
>
>
> ---------------------------------------------------------------------------------------------------------
> Problem prob04.cmpl
> Nr. of variables 3
> Nr. of constraints 2
> Objective name line[1]
> Solver name CBC
> Display variables (all)
> Display constraints (all)
>
> ---------------------------------------------------------------------------------------------------------
> Objective status optimal
> Objective value 3.8961 (max!)
> Variables
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> x[1] C 0
> 0 Infinity -0.454545
> x[2] C 1.94805
> 0 Infinity 0
> x[3] C 0
> 0 Infinity -0.727273
>
> ---------------------------------------------------------------------------------------------------------
> Constraints
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> line[2] L 15
> -Infinity 15 0.25974
> line[3] L 8.18182
> -Infinity 20 0
>
> ---------------------------------------------------------------------------------------------------------
> This is obviously not optimal. Now if I read the data directly from inside
> the CMPL file, I get the correct answer:
>
>
> ---------------------------------------------------------------------------------------------------------
> Problem prob04.cmpl
> Nr. of variables 3
> Nr. of constraints 2
> Objective name line[1]
> Solver name CBC
> Display variables (all)
> Display constraints (all)
>
> ---------------------------------------------------------------------------------------------------------
> Objective status optimal
> Objective value 4.28571 (max!)
> Variables
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> x[1] C 0
> 0 Infinity -0.6
> x[2] C 0
> 0 Infinity -0.2
> x[3] C 1.42857
> 0 Infinity 0
>
> ---------------------------------------------------------------------------------------------------------
> Constraints
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> line[2] L 15
> -Infinity 15 0.285714
> line[3] L 15.8571
> -Infinity 20 0
>
> ---------------------------------------------------------------------------------------------------------
> Any thoughts on why this is happening?
>
> The contents of the CSV files are exactly as mentioned in page 31.
>
> Regards,
> Indrajit
>
>
>
> _______________________________________________
> Cmpl mailing list
> Cmpl at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cmpl
>
> Am 23.11.2014 um 20:05 schrieb Indrajit Sen Gupta <indrajitsg at gmail.com>:
>
> Hi Mike,
>
> I am trying out one of the examples from the manual (Pg 31):
>
> -------------------------------------------------------------------
> %arg -solver cbc
> %arg -solutionAscii
> parameters:
> # Reading data from CSV
> c[] := readcsv("c.csv");
> b[] := readcsv("b.csv");
> A[,] := readcsv("a.csv");
> # Reading data directly
> # c[] := (1,2,3);
> # b[] := (15,20);
> # A[,] := ((5.6, 7.7, 10.5),
> # (9.8, 4.2, 11.1));
>
> variables:
> x[defset(c[])] : real[0..];
>
> objectives:
> c[]T * x[] -> max;
> constraints:
> A[,] * x[] <= b[];
> -------------------------------------------------------------------
> When I use the readcsv command to read the data, this is the output that I
> get:
>
>
> ---------------------------------------------------------------------------------------------------------
> Problem prob04.cmpl
> Nr. of variables 3
> Nr. of constraints 2
> Objective name line[1]
> Solver name CBC
> Display variables (all)
> Display constraints (all)
>
> ---------------------------------------------------------------------------------------------------------
> Objective status optimal
> Objective value 3.8961 (max!)
> Variables
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> x[1] C 0
> 0 Infinity -0.454545
> x[2] C 1.94805
> 0 Infinity 0
> x[3] C 0
> 0 Infinity -0.727273
>
> ---------------------------------------------------------------------------------------------------------
> Constraints
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> line[2] L 15
> -Infinity 15 0.25974
> line[3] L 8.18182
> -Infinity 20 0
>
> ---------------------------------------------------------------------------------------------------------
> This is obviously not optimal. Now if I read the data directly from inside
> the CMPL file, I get the correct answer:
>
>
> ---------------------------------------------------------------------------------------------------------
> Problem prob04.cmpl
> Nr. of variables 3
> Nr. of constraints 2
> Objective name line[1]
> Solver name CBC
> Display variables (all)
> Display constraints (all)
>
> ---------------------------------------------------------------------------------------------------------
> Objective status optimal
> Objective value 4.28571 (max!)
> Variables
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> x[1] C 0
> 0 Infinity -0.6
> x[2] C 0
> 0 Infinity -0.2
> x[3] C 1.42857
> 0 Infinity 0
>
> ---------------------------------------------------------------------------------------------------------
> Constraints
> Name Type Activity Lower bound
> Upper bound Marginal
>
> ---------------------------------------------------------------------------------------------------------
> line[2] L 15
> -Infinity 15 0.285714
> line[3] L 15.8571
> -Infinity 20 0
>
> ---------------------------------------------------------------------------------------------------------
> Any thoughts on why this is happening?
>
> The contents of the CSV files are exactly as mentioned in page 31.
>
> Regards,
> Indrajit
>
>
>
> _______________________________________________
> Cmpl mailing list
> Cmpl at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cmpl
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20141124/ce02c433/attachment.html>
More information about the Cmpl
mailing list