Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    Math::LP 0.03

    Download button

    No screenshots available
    Downloads: 364  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.8/5)
    7 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Wim Verhaegen | More programs
    Perl Artistic License / FREE
    January 21st, 2008, 14:47 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Math::LP description

    Math::LP is an OO interface to linear programs.

    Math::LP is an OO interface to linear programs.

    SYNOPSIS

    use Math::LP qw(:types); # imports optimization types
    use Math::LP::Constraint qw(:types); # imports constraint types

    # make a new LP
    $lp = new Math::LP;

    # make the variables for the LP
    $x1 = new Math::LP::Variable(name => 'x1');
    $x2 = new Math::LP::Variable(name => 'x2');

    # maximize the objective function to x1 + 2 x2
    $obj_fn = make Math::LP::LinearCombination($x1,1.0,$x2,2.0);
    $lp->maximize_for($obj_fn);

    # add the constraint x1 + x2 make Math::LP::LinearCombination($x1,1.0,$x2,1.0),
    rhs => 2.0,
    type => $LE,
    );
    $lp->add_constraint($constr);

    # solve the LP and print the results
    $lp->solve() or die "Could not solve the LP";
    print "Optimum = ", $obj_fn->{value}, "n";
    print "x1 = ", $x1->{value}, "n";
    print "x2 = ", $x1->{value}, "n";
    print "slack = ", $constr->{slack}, "n";

    The Math::LP package provides an object oriented interface to defining and solving mixed linear/integer programs. It uses the lp_solve library as the underlying solver. Please note that this is not a two way relation. An LP is defined using Math::LP, converted to an lp_solve data structure, and solved with lp_solve functions. It is not possible to grab an lp_solve structure somehow and convert it to a Math::LP object for manipulation and inspection. If you want to do that kind of stuff in Perl, use the Math::LP::Solve package instead.

    That being said, the logical way of constructing an LP consists of:

    1. Construct Math::LP::Variable objects, in the meanwhile marking integer variables
    2. Construct Math::LP::LinearCombination objects with the variables and use them as the objective function and constraints
    3. Solve the LP
    4. Fetch the variable values from the Math::LP::Variable objects, the slacks and dual values from the Math::LP::Constraint objects. and the row values (including the optimum) from the corresponding Math::LP::LinearCombination.

    Requirements:

    · Perl



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    OO interface | linear programs | Perl module | object-oriented | OO | interface

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM