public Inventory solveFractional() {
        int availableCapacity = capacity;
        ArrayList<Double> amounts = new ArrayList<Double>();
        if (availableCapacity <= 0) {
            return new Inventory(this, amounts);
        }
        for (Item i : items) {
            if (availableCapacity < i.getWeight()) {
                amounts.add(((double) availableCapacity) / i.getWeight());
                return new Inventory(this, amounts);
            }
            availableCapacity -= i.getWeight();
            amounts.add(1.0);
        }
        return new Inventory(this, amounts);
    }