GithubHelp home page GithubHelp logo

isabellavieira57 / knapsack-problem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from keccah/paa-trabalho

0.0 1.0 1.0 32 KB

Algorithm to solve the fractional knapsack, binary knapsack, and knapsack with conflicts problem.

Python 99.48% Shell 0.45% Batchfile 0.06%

knapsack-problem's Introduction

Algorithm Design Coursework

The purpose of this project is to solve the fractional knapsack, binary knapsack and the knapsack with conflict problem.

How to run

./trabalho <instance_path> <question>

where:

  • Question 1 is the fractional knapsack problem
  • Question 2 is the binary knapsack problem
  • Question 3 is the knapsack with conflicts problem

Example

./trabalho data 1

Instance Format

Input format

The input file should be in the following format:

NbItems KnapsackSize
<< And then for each item >>
Index Profit Weight [List_Of_Conflict_Items]

Output format

The output file should be in the following format:

NbItemsUsed TotalWeight TotalProfit
<< And then for each item placed in the knapsack >>
ItemIndex FractionOfItem

Some remarks

  • The second field "FractionOfItem" belongs between [0,1]. For the questions 2 and 3, they should always be set to 1 (item cannot be fractioned).

  • The instances are common for all three questions. They include all the information: weight, profit for the items as well as their conflicts (for question 3).

knapsack-problem's People

Contributors

keccah avatar ferreira-isa avatar

Watchers

James Cloos avatar

Forkers

ferreira-isa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.