lemon-project-template-glpk

annotate src/main.cc @ 11:4fc6ad2fb8a6

Test GLPK in src/main.cc
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 21:43:29 +0100
parents c941f748eaa8
children
rev   line source
alpar@0 1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@0 2 *
alpar@0 3 * This file is a part of LEMON, a generic C++ optimization library.
alpar@0 4 *
alpar@0 5 * Copyright (C) 2003-2009
alpar@0 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@0 7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@0 8 *
alpar@0 9 * Permission to use, modify and distribute this software is granted
alpar@0 10 * provided that this copyright notice appears in all copies. For
alpar@0 11 * precise terms see the accompanying LICENSE file.
alpar@0 12 *
alpar@0 13 * This software is provided "AS IS" with no warranty of any kind,
alpar@0 14 * express or implied, and with no claim as to its suitability for any
alpar@0 15 * purpose.
alpar@0 16 *
alpar@0 17 */
alpar@0 18
alpar@11 19 #include<lemon/arg_parser.h>
alpar@0 20 #include<lemon/list_graph.h>
alpar@11 21 #include<lemon/glpk.h>
alpar@0 22
alpar@0 23 ///The main entry point
alpar@11 24 int main(int argc, char **argv)
alpar@0 25 {
alpar@11 26
alpar@11 27 lemon::ArgParser ap(argc,argv);
alpar@11 28 ap.run();
alpar@11 29
alpar@0 30 lemon::ListGraph g;
alpar@0 31 g.addNode();
alpar@11 32
alpar@11 33 typedef lemon::GlpkLp Solver;
alpar@11 34 Solver lp;
alpar@11 35 Solver::Col x = lp.addCol();
alpar@11 36 Solver::Col y = lp.addCol();
alpar@11 37 lp.colLowerBound(x,0);
alpar@11 38 lp.colLowerBound(y,0);
alpar@11 39 lp.addRow(3<=x+2*y<=10);
alpar@11 40 lp.obj(-4*x+3*y);
alpar@11 41 lp.max();
alpar@11 42 lp.solve();
alpar@11 43
alpar@0 44 }