[FlopCpp] wrote first flopcpp model. have a lot of questions

Mario Rappi marappi at wichita.edu
Sat Nov 28 20:46:59 EST 2009


First I include the model, then the output, and at the end the questions:

*****model************************
// $Id$
#include "flopc.hpp"
using namespace flopc;
#include <OsiClpSolverInterface.hpp>

int main() {

    MP_model &model = MP_model::getDefaultModel();
    model.setSolver(new OsiClpSolverInterface);
    model.verbose();

    enum {storeA, storeB, storeC, storeD, numS};
    enum {Input1, Input2, numI};
    enum {Output1, numO};

    MP_set S(numS);         // Stores
    MP_set I(numI);            // Inputs
    MP_set O(numO);            // Outputs

    MP_subset<2> Input(S,I);
    Input.insert(S,I);
    Input.display("Input");
    MP_subset<2> Output(S,O);
    Output.insert(S,O);
    Output.display("Output");

    //this will be easier with an array??
    MP_data InputVal(Input);
    InputVal(storeA,Input1)=1; InputVal(storeA,Input2)=3;
    InputVal(storeB,Input1)=3; InputVal(storeB,Input2)=3;
    InputVal(storeC,Input1)=4; InputVal(storeC,Input2)=2;
    InputVal(storeD,Input1)=3; InputVal(storeD,Input2)=1;

    MP_data OutputVal(Output);
    OutputVal(storeA,Output1)=1;
    OutputVal(storeB,Output1)=1.5;
    OutputVal(storeC,Output1)=2;
    OutputVal(storeD,Output1)=1;

    MP_variable x(I), y(O);
    x.lowerLimit(I)=0;
    y.lowerLimit(O)=0;

    MP_constraint efficiency(S);
    efficiency(S) = sum(I, InputVal(S, I) * x(I)) <= sum(O, OutputVal(S, O)
* y(O));

    minimize( (sum(O, OutputVal(storeB, O) * y(O))) - (sum(I,
InputVal(storeB, I) * x(I))));

    efficiency.display("constraints");
    x.display("x");
    y.display("y");

    cout<<"Test dea passed."<<endl;
}
*****model end************************

*****output************************
Input
Output
FlopCpp: Constraint
0   1  0  0
1   1  0  0
2   1  0  0
3   1  0  0
0   2  0  0
1   2  0  0
2   2  0  0
3   2  0  0
0   0  -0  0
1   0  -0  0
2   0  -0  0
3   0  -0  0
FlopCpp: Number of constraint blocks: 1
FlopCpp: Number of individual constraints: 4
FlopCpp: Number of variable blocks: 2
FlopCpp: Number of individual variables: 3
FlopCpp: Number of non-zeroes (including rhs): 12
Objective
-1   0  0
-1   1  -0
-1   2  -0
FlopCpp: Generation time: -2.64274e-19
Clp0000I Optimal - objective value 0
Clp0032I Optimal objective 0 - 0 iterations time 0.002
FlopCpp: Optimal obj. value = 0
FlopCpp: Solver(m, n, nz) = 4  3  0
constraints
0  -1.79769e+308  0  0  -0
1  -1.79769e+308  0  0  -0
2  -1.79769e+308  0  0  -0
3  -1.79769e+308  0  0  -0
x
0   0
1   0
y
0   0
Test dea passed.
*****output end************************

*****Questions:******************
I would like to define a set A that includes all members of O and I and then
derive O and I from A.
This is what I am thinking in GAMS terms:
A        / Input1, Input2, Output1 /
O(A)   /  Input1, Input2 /
I(A)    / Output1  /
Is this possible?. I thought it would allow me to write the model more
easily (but may be not)
*******************
I tried to display the constraints but I didn't get what I was expecting
(the actual mathematical expression). Is it possible to see the constraints
in any other way?
*******************
When I compile I get the following two warnings. Should I be concerned? How
do I fix them?

c:\program files\coin-flopcpp\flopcpp\src\mp_set.hpp(259) : warning C4267:
'return' : conversion from 'size_t' to 'int', possible loss of data
        c:\program files\coin-flopcpp\flopcpp\src\mp_set.hpp(258) : while
compiling class template member function 'int
flopc::MP_subset<nbr>::size(void) const'
        with
        [
            nbr=2
        ]
        c:\program files\coin-flopcpp\flopcpp\examples\dea.cpp(21) : see
reference to class template instantiation 'flopc::MP_subset<nbr>' being
compiled
        with
        [
            nbr=2
        ]
c:\program files\coin-flopcpp\flopcpp\src\mp_set.hpp(243) : warning C4267:
'initializing' : conversion from 'size_t' to 'const int', possible loss of
data
        c:\program files\coin-flopcpp\flopcpp\src\mp_set.hpp(232) : while
compiling class template member function 'void
flopc::MP_subset<nbr>::insert(const std::vector<_Ty> &)'
        with
        [
            nbr=2,
            _Ty=int
        ]

*******************
The objective function that I really want to use is
maximize( (sum(O, OutputVal(storeB, O) * y(O))) / (sum(I, InputVal(storeB,
I) * x(I))));
But it doesn't compile, I get this error:

c:\program files\coin-flopcpp\flopcpp\examples\dea.cpp(51) : error C2678:
binary '/' : no operator found which takes a left-hand operand of type
'flopc::MP_expression' (or there is no acceptable conversion)
        c:\program files\coin-flopcpp\flopcpp\src\mp_constant.hpp(141):
could be 'flopc::Constant flopc::operator /(const flopc::Constant &,const
flopc::Constant &)'
        c:\program
files\coin-flopcpp\coinutils\src\coinpackedvector.hpp(483): or
'CoinPackedVector operator /(const CoinPackedVectorBase &,const
CoinPackedVectorBase &)'
        c:\program
files\coin-flopcpp\coinutils\src\coinpackedvector.hpp(583): or
'CoinPackedVector operator /(const CoinPackedVectorBase &,double)'
        c:\program
files\coin-flopcpp\coinutils\src\coinpackedvector.hpp(625): or
'CoinPackedVector operator /(double,const CoinPackedVectorBase &)'
        while trying to match the argument list '(flopc::MP_expression,
flopc::MP_expression)'

I am using MSVCPP, I read of some problems specific to VCPP so I tried the
same in Linux(I think it is build-essential in Ubuntu) but I get the same
errors.
How can I fix this problem with the division operation?
*******************
Is my formulation of the objective function OK in how I sum only for storeB
or do I have to use such_that or any other type of control?
How do I display the objective function?
*******************
What are these numbers in the output?
constraints
0  -1.79769e+308  0  0  -0
1  -1.79769e+308  0  0  -0
2  -1.79769e+308  0  0  -0
3  -1.79769e+308  0  0  -0
My four constraints are supposed to have only three terms (two on the left
and one on the right)
********************
What is this?
Objective
-1   0  0
-1   1  -0
-1   2  -0
********************

If it helps at all: the model is a simple DEA formulation (primal).
I understand some of my questions may be more C++ than flopcpp questions but
I can't tell.
I will appreciate help on any of these questions and on any other comments
you may have on the model formulation.
Thanks in advance.
Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/flopcpp/attachments/20091128/aadcc90b/attachment.html 


More information about the FlopCpp mailing list