<jupyter_start><jupyter_text>Farm Model  Import FlipsImport Flips and open `System`, `Flips.Domain`, and `Flips.Solve`<jupyter_code>#r "nuget: Flips, Version=1.2.3"

open System
open Flips.Domain
open Flips.Solve<jupyter_output><empty_output><jupyter_text>Step 1: Create the Decision Variables<jupyter_code>// Create decision variables for cows, pigs, and chickens
let numberOfCows = Decision.createContinuous "NumberOfCows" 0.0 infinity
let numberOfPigs = Decision.createContinuous "NumberOfPigs" 0.0 infinity
let numberOfChickens = Decision.createContinuous "NumberOfChickens" 0.0 infinity<jupyter_output><empty_output><jupyter_text>Step 2: Create the Objective<jupyter_code>// Create an objective expression
let objectiveExpression = 100.0*numberOfCows+50.0*numberOfPigs+8.0*numberOfChickens
// Create an objective
let objective = Objective.create "MaximizeRevenue" Maximize objectiveExpression<jupyter_output><empty_output><jupyter_text>Step 3: Add Constraints<jupyter_code>// Add constraint for amount of Pasture
let maxPasture = Constraint.create "MaxPasture" (1.0*numberOfCows + 0.2*numberOfPigs <== 1000.0)
// Add constraint for amount of Feed
let maxFeed = Constraint.create "MaxFeed" (1.0*numberOfPigs + 0.1*numberOfChickens <== 100.0)
// Add constraint for amount of Labor
let maxLabor = Constraint.create "MaxLabor" (9.5*numberOfCows + 8.0*numberOfPigs <== 7200.0)<jupyter_output><empty_output><jupyter_text>Step 4: Create the model<jupyter_code>// Create the model and add the constraints
let model =
    Model.create objective
    |> Model.addConstraint maxPasture
    |> Model.addConstraint maxFeed
    |> Model.addConstraint maxLabor<jupyter_output><empty_output><jupyter_text>Step 5: Create the Settings and Solve<jupyter_code>// Create the solver settings
let settings = {
    SolverType = SolverType.CBC
    MaxDuration = 10000L
    WriteLPFile = None
}
// Solve the model and save the results
let result = solve settings model<jupyter_output><empty_output><jupyter_text>Step 6: Print Results<jupyter_code>printfn "--Results--"
// Print the results of the solver
match result with
| Suboptimal msg -> printfn "Unable to solve. Error: %s" msg
| Optimal solution ->
    printfn "Objective Value: %f" solution.ObjectiveResult

    for (decision, value) in solution.DecisionResults |> Map.toSeq do
        let (DecisionName name) = decision.Name
        printfn "Decision: %s\tValue: %f" name value<jupyter_output>Stopped due to error
{'fraction_non_alphanumeric': 0.09636586361780318, 'fraction_numerical': 0.022458146182115148, 'mean_word_length': 5.639566395663957, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '429026', 'license': 'MIT', 'n_tokens_mistral': 854, 'n_tokens_neox': 784, 'n_words': 213, 'path': 'code/fsharp-workshop/Practice/.ipynb_checkpoints/Ex02_FarmModel-checkpoint.ipynb', 'repo_name': 'houstonhaynes/MathematicalPlanning101', 'size': '2449'}