[Cmpl] Suboptimal solution when reading from CSV
Indrajit Sen Gupta
indrajitsg at gmail.com
Sun Nov 23 14:05:43 EST 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20141124/113c769a/attachment.html>
More information about the Cmpl
mailing list