1(* 2Copyright 2010-2021 Google 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14*) 15 16open Google.OrTools.FSharp 17 18let profits = [ 360L; 83L; 59L; 130L; 431L; 67L; 230L; 52L; 93L; 125L; 670L; 892L; 600L; 38L; 48L; 147L; 78L; 256L; 63L; 17L; 120L; 164L; 432L; 35L; 92L; 110L; 22L; 42L; 50L; 323L; 514L; 28L; 87L; 73L; 78L; 15L; 26L; 78L; 210L; 36L; 85L; 189L; 274L; 43L; 33L; 10L; 19L; 389L; 276L; 312L ] 19let weights = array2D [ [ 7L; 0L; 30L; 22L; 80L; 94L; 11L; 81L; 70L; 64L; 59L; 18L; 0L; 2036L; 3L; 8L; 15L; 42L; 9L; 0L; 42L; 47L; 52L; 32L; 26L; 48L; 55L; 6L; 29L; 84L; 212L; 4L; 18L; 56L; 7L; 29L; 93L; 44L; 71L; 3L; 86L; 66L; 31L; 65L; 0L; 79L; 20L; 2265L; 52L; 13L ] ] 23let capacities = [ 850L ] 24 25printfn "Solving knapsack with %i items and %i dimensions" (profits.Length) (weights.Length) 26 27let ks = knapsackSolve "test" KnapsackSolverAlgorithm.MultidimensionBranchAndBound profits weights capacities 28let computedProfit = ks.Solve(); 29let expectedProfit = 7534L 30printfn "Optimal Profit = %d \nexpected = %d \nOptimal Soltion = %b " computedProfit expectedProfit (ks.IsSolutionOptimal()) 31