text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: application_insights
using AWS.Compat
using AWS.UUIDs

"""
    create_application(resource_group_name)
    create_application(resource_group_name, params::Dict{String,<:Any})

Adds an application that is created from a resource group.

# Arguments
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"CWEMonitorEnabled"`:  Indicates whether Application Insights can listen to CloudWatch
  events for the application resources, such as instance terminated, failed deployment, and
  others.
- `"OpsCenterEnabled"`:  When set to true, creates opsItems for any problems detected on an
  application.
- `"OpsItemSNSTopicArn"`:  The SNS topic provided to Application Insights that is
  associated to the created opsItem. Allows you to receive notifications for updates to the
  opsItem.
- `"Tags"`: List of tags to add to the application. tag key (Key) and an associated tag
  value (Value). The maximum length of a tag key is 128 characters. The maximum length of a
  tag value is 256 characters.
"""
function create_application(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "CreateApplication",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_application(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "CreateApplication",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_component(component_name, resource_group_name, resource_list)
    create_component(component_name, resource_group_name, resource_list, params::Dict{String,<:Any})

Creates a custom component by grouping similar standalone instances to monitor.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.
- `resource_list`: The list of resource ARNs that belong to the component.

"""
function create_component(
    ComponentName,
    ResourceGroupName,
    ResourceList;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "CreateComponent",
        Dict{String,Any}(
            "ComponentName" => ComponentName,
            "ResourceGroupName" => ResourceGroupName,
            "ResourceList" => ResourceList,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_component(
    ComponentName,
    ResourceGroupName,
    ResourceList,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "CreateComponent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                    "ResourceList" => ResourceList,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_log_pattern(pattern, pattern_name, pattern_set_name, rank, resource_group_name)
    create_log_pattern(pattern, pattern_name, pattern_set_name, rank, resource_group_name, params::Dict{String,<:Any})

Adds an log pattern to a LogPatternSet.

# Arguments
- `pattern`: The log pattern. The pattern must be DFA compatible. Patterns that utilize
  forward lookahead or backreference constructions are not supported.
- `pattern_name`: The name of the log pattern.
- `pattern_set_name`: The name of the log pattern set.
- `rank`: Rank of the log pattern. Must be a value between 1 and 1,000,000. The patterns
  are sorted by rank, so we recommend that you set your highest priority patterns with the
  lowest rank. A pattern of rank 1 will be the first to get matched to a log line. A pattern
  of rank 1,000,000 will be last to get matched. When you configure custom log patterns from
  the console, a Low severity pattern translates to a 750,000 rank. A Medium severity pattern
  translates to a 500,000 rank. And a High severity pattern translates to a 250,000 rank.
  Rank values less than 1 or greater than 1,000,000 are reserved for AWS-provided patterns.
- `resource_group_name`: The name of the resource group.

"""
function create_log_pattern(
    Pattern,
    PatternName,
    PatternSetName,
    Rank,
    ResourceGroupName;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "CreateLogPattern",
        Dict{String,Any}(
            "Pattern" => Pattern,
            "PatternName" => PatternName,
            "PatternSetName" => PatternSetName,
            "Rank" => Rank,
            "ResourceGroupName" => ResourceGroupName,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_log_pattern(
    Pattern,
    PatternName,
    PatternSetName,
    Rank,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "CreateLogPattern",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "Pattern" => Pattern,
                    "PatternName" => PatternName,
                    "PatternSetName" => PatternSetName,
                    "Rank" => Rank,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_application(resource_group_name)
    delete_application(resource_group_name, params::Dict{String,<:Any})

Removes the specified application from monitoring. Does not delete the application.

# Arguments
- `resource_group_name`: The name of the resource group.

"""
function delete_application(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DeleteApplication",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_application(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DeleteApplication",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_component(component_name, resource_group_name)
    delete_component(component_name, resource_group_name, params::Dict{String,<:Any})

Ungroups a custom component. When you ungroup custom components, all applicable monitors
that are set up for the component are removed and the instances revert to their standalone
status.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.

"""
function delete_component(
    ComponentName, ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DeleteComponent",
        Dict{String,Any}(
            "ComponentName" => ComponentName, "ResourceGroupName" => ResourceGroupName
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_component(
    ComponentName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DeleteComponent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_log_pattern(pattern_name, pattern_set_name, resource_group_name)
    delete_log_pattern(pattern_name, pattern_set_name, resource_group_name, params::Dict{String,<:Any})

Removes the specified log pattern from a LogPatternSet.

# Arguments
- `pattern_name`: The name of the log pattern.
- `pattern_set_name`: The name of the log pattern set.
- `resource_group_name`: The name of the resource group.

"""
function delete_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DeleteLogPattern",
        Dict{String,Any}(
            "PatternName" => PatternName,
            "PatternSetName" => PatternSetName,
            "ResourceGroupName" => ResourceGroupName,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DeleteLogPattern",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "PatternName" => PatternName,
                    "PatternSetName" => PatternSetName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_application(resource_group_name)
    describe_application(resource_group_name, params::Dict{String,<:Any})

Describes the application.

# Arguments
- `resource_group_name`: The name of the resource group.

"""
function describe_application(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DescribeApplication",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_application(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeApplication",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_component(component_name, resource_group_name)
    describe_component(component_name, resource_group_name, params::Dict{String,<:Any})

Describes a component and lists the resources that are grouped together in a component.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.

"""
function describe_component(
    ComponentName, ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DescribeComponent",
        Dict{String,Any}(
            "ComponentName" => ComponentName, "ResourceGroupName" => ResourceGroupName
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_component(
    ComponentName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeComponent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_component_configuration(component_name, resource_group_name)
    describe_component_configuration(component_name, resource_group_name, params::Dict{String,<:Any})

Describes the monitoring configuration of the component.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.

"""
function describe_component_configuration(
    ComponentName, ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DescribeComponentConfiguration",
        Dict{String,Any}(
            "ComponentName" => ComponentName, "ResourceGroupName" => ResourceGroupName
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_component_configuration(
    ComponentName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeComponentConfiguration",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_component_configuration_recommendation(component_name, resource_group_name, tier)
    describe_component_configuration_recommendation(component_name, resource_group_name, tier, params::Dict{String,<:Any})

Describes the recommended monitoring configuration of the component.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.
- `tier`: The tier of the application component. Supported tiers include DOT_NET_CORE,
  DOT_NET_WORKER, DOT_NET_WEB, SQL_SERVER, and DEFAULT.

"""
function describe_component_configuration_recommendation(
    ComponentName,
    ResourceGroupName,
    Tier;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeComponentConfigurationRecommendation",
        Dict{String,Any}(
            "ComponentName" => ComponentName,
            "ResourceGroupName" => ResourceGroupName,
            "Tier" => Tier,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_component_configuration_recommendation(
    ComponentName,
    ResourceGroupName,
    Tier,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeComponentConfigurationRecommendation",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                    "Tier" => Tier,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_log_pattern(pattern_name, pattern_set_name, resource_group_name)
    describe_log_pattern(pattern_name, pattern_set_name, resource_group_name, params::Dict{String,<:Any})

Describe a specific log pattern from a LogPatternSet.

# Arguments
- `pattern_name`: The name of the log pattern.
- `pattern_set_name`: The name of the log pattern set.
- `resource_group_name`: The name of the resource group.

"""
function describe_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeLogPattern",
        Dict{String,Any}(
            "PatternName" => PatternName,
            "PatternSetName" => PatternSetName,
            "ResourceGroupName" => ResourceGroupName,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeLogPattern",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "PatternName" => PatternName,
                    "PatternSetName" => PatternSetName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_observation(observation_id)
    describe_observation(observation_id, params::Dict{String,<:Any})

Describes an anomaly or error with the application.

# Arguments
- `observation_id`: The ID of the observation.

"""
function describe_observation(
    ObservationId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DescribeObservation",
        Dict{String,Any}("ObservationId" => ObservationId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_observation(
    ObservationId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeObservation",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("ObservationId" => ObservationId), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_problem(problem_id)
    describe_problem(problem_id, params::Dict{String,<:Any})

Describes an application problem.

# Arguments
- `problem_id`: The ID of the problem.

"""
function describe_problem(ProblemId; aws_config::AbstractAWSConfig=global_aws_config())
    return application_insights(
        "DescribeProblem",
        Dict{String,Any}("ProblemId" => ProblemId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_problem(
    ProblemId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeProblem",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("ProblemId" => ProblemId), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    describe_problem_observations(problem_id)
    describe_problem_observations(problem_id, params::Dict{String,<:Any})

Describes the anomalies or errors associated with the problem.

# Arguments
- `problem_id`: The ID of the problem.

"""
function describe_problem_observations(
    ProblemId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "DescribeProblemObservations",
        Dict{String,Any}("ProblemId" => ProblemId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_problem_observations(
    ProblemId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "DescribeProblemObservations",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("ProblemId" => ProblemId), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    list_applications()
    list_applications(params::Dict{String,<:Any})

Lists the IDs of the applications that you are monitoring.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"MaxResults"`: The maximum number of results to return in a single call. To retrieve the
  remaining results, make another call with the returned NextToken value.
- `"NextToken"`: The token to request the next page of results.
"""
function list_applications(; aws_config::AbstractAWSConfig=global_aws_config())
    return application_insights(
        "ListApplications"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_applications(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListApplications", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

"""
    list_components(resource_group_name)
    list_components(resource_group_name, params::Dict{String,<:Any})

Lists the auto-grouped, standalone, and custom components of the application.

# Arguments
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"MaxResults"`: The maximum number of results to return in a single call. To retrieve the
  remaining results, make another call with the returned NextToken value.
- `"NextToken"`: The token to request the next page of results.
"""
function list_components(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListComponents",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_components(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "ListComponents",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    list_configuration_history()
    list_configuration_history(params::Dict{String,<:Any})

 Lists the INFO, WARN, and ERROR events for periodic configuration updates performed by
Application Insights. Examples of events represented are:    INFO: creating a new alarm or
updating an alarm threshold.   WARN: alarm not created due to insufficient data points used
to predict thresholds.   ERROR: alarm not created due to permission errors or exceeding
quotas.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"EndTime"`: The end time of the event.
- `"EventStatus"`: The status of the configuration update event. Possible values include
  INFO, WARN, and ERROR.
- `"MaxResults"`:  The maximum number of results returned by ListConfigurationHistory in
  paginated output. When this parameter is used, ListConfigurationHistory returns only
  MaxResults in a single page along with a NextToken response element. The remaining results
  of the initial request can be seen by sending another ListConfigurationHistory request with
  the returned NextToken value. If this parameter is not used, then ListConfigurationHistory
  returns all results.
- `"NextToken"`: The NextToken value returned from a previous paginated
  ListConfigurationHistory request where MaxResults was used and the results exceeded the
  value of that parameter. Pagination continues from the end of the previous results that
  returned the NextToken value. This value is null when there are no more results to return.
- `"ResourceGroupName"`: Resource group to which the application belongs.
- `"StartTime"`: The start time of the event.
"""
function list_configuration_history(; aws_config::AbstractAWSConfig=global_aws_config())
    return application_insights(
        "ListConfigurationHistory"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_configuration_history(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListConfigurationHistory",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    list_log_pattern_sets(resource_group_name)
    list_log_pattern_sets(resource_group_name, params::Dict{String,<:Any})

Lists the log pattern sets in the specific application.

# Arguments
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"MaxResults"`: The maximum number of results to return in a single call. To retrieve the
  remaining results, make another call with the returned NextToken value.
- `"NextToken"`: The token to request the next page of results.
"""
function list_log_pattern_sets(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListLogPatternSets",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_log_pattern_sets(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "ListLogPatternSets",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    list_log_patterns(resource_group_name)
    list_log_patterns(resource_group_name, params::Dict{String,<:Any})

Lists the log patterns in the specific log LogPatternSet.

# Arguments
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"MaxResults"`: The maximum number of results to return in a single call. To retrieve the
  remaining results, make another call with the returned NextToken value.
- `"NextToken"`: The token to request the next page of results.
- `"PatternSetName"`: The name of the log pattern set.
"""
function list_log_patterns(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListLogPatterns",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_log_patterns(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "ListLogPatterns",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    list_problems()
    list_problems(params::Dict{String,<:Any})

Lists the problems with your application.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"EndTime"`: The time when the problem ended, in epoch seconds. If not specified,
  problems within the past seven days are returned.
- `"MaxResults"`: The maximum number of results to return in a single call. To retrieve the
  remaining results, make another call with the returned NextToken value.
- `"NextToken"`: The token to request the next page of results.
- `"ResourceGroupName"`: The name of the resource group.
- `"StartTime"`: The time when the problem was detected, in epoch seconds. If you don't
  specify a time frame for the request, problems within the past seven days are returned.
"""
function list_problems(; aws_config::AbstractAWSConfig=global_aws_config())
    return application_insights(
        "ListProblems"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_problems(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListProblems", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

"""
    list_tags_for_resource(resource_arn)
    list_tags_for_resource(resource_arn, params::Dict{String,<:Any})

Retrieve a list of the tags (keys and values) that are associated with a specified
application. A tag is a label that you optionally define and associate with an application.
Each tag consists of a required tag key and an optional associated tag value. A tag key is
a general label that acts as a category for more specific tag values. A tag value acts as a
descriptor within a tag key.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the application that you want to
  retrieve tag information for.

"""
function list_tags_for_resource(
    ResourceARN; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "ListTagsForResource",
        Dict{String,Any}("ResourceARN" => ResourceARN);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_tags_for_resource(
    ResourceARN,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "ListTagsForResource",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("ResourceARN" => ResourceARN), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    tag_resource(resource_arn, tags)
    tag_resource(resource_arn, tags, params::Dict{String,<:Any})

Add one or more tags (keys and values) to a specified application. A tag is a label that
you optionally define and associate with an application. Tags can help you categorize and
manage application in different ways, such as by purpose, owner, environment, or other
criteria.  Each tag consists of a required tag key and an associated tag value, both of
which you define. A tag key is a general label that acts as a category for more specific
tag values. A tag value acts as a descriptor within a tag key.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the application that you want to add
  one or more tags to.
- `tags`: A list of tags that to add to the application. A tag consists of a required tag
  key (Key) and an associated tag value (Value). The maximum length of a tag key is 128
  characters. The maximum length of a tag value is 256 characters.

"""
function tag_resource(ResourceARN, Tags; aws_config::AbstractAWSConfig=global_aws_config())
    return application_insights(
        "TagResource",
        Dict{String,Any}("ResourceARN" => ResourceARN, "Tags" => Tags);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function tag_resource(
    ResourceARN,
    Tags,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "TagResource",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("ResourceARN" => ResourceARN, "Tags" => Tags),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    untag_resource(resource_arn, tag_keys)
    untag_resource(resource_arn, tag_keys, params::Dict{String,<:Any})

Remove one or more tags (keys and values) from a specified application.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the application that you want to remove
  one or more tags from.
- `tag_keys`: The tags (tag keys) that you want to remove from the resource. When you
  specify a tag key, the action removes both that key and its associated tag value. To remove
  more than one tag from the application, append the TagKeys parameter and argument for each
  additional tag to remove, separated by an ampersand.

"""
function untag_resource(
    ResourceARN, TagKeys; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "UntagResource",
        Dict{String,Any}("ResourceARN" => ResourceARN, "TagKeys" => TagKeys);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function untag_resource(
    ResourceARN,
    TagKeys,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UntagResource",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("ResourceARN" => ResourceARN, "TagKeys" => TagKeys),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_application(resource_group_name)
    update_application(resource_group_name, params::Dict{String,<:Any})

Updates the application.

# Arguments
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"CWEMonitorEnabled"`:  Indicates whether Application Insights can listen to CloudWatch
  events for the application resources, such as instance terminated, failed deployment, and
  others.
- `"OpsCenterEnabled"`:  When set to true, creates opsItems for any problems detected on an
  application.
- `"OpsItemSNSTopicArn"`:  The SNS topic provided to Application Insights that is
  associated to the created opsItem. Allows you to receive notifications for updates to the
  opsItem.
- `"RemoveSNSTopic"`:  Disassociates the SNS topic from the opsItem created for detected
  problems.
"""
function update_application(
    ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "UpdateApplication",
        Dict{String,Any}("ResourceGroupName" => ResourceGroupName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_application(
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UpdateApplication",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("ResourceGroupName" => ResourceGroupName), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_component(component_name, resource_group_name)
    update_component(component_name, resource_group_name, params::Dict{String,<:Any})

Updates the custom component name and/or the list of resources that make up the component.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NewComponentName"`: The new name of the component.
- `"ResourceList"`: The list of resource ARNs that belong to the component.
"""
function update_component(
    ComponentName, ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "UpdateComponent",
        Dict{String,Any}(
            "ComponentName" => ComponentName, "ResourceGroupName" => ResourceGroupName
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_component(
    ComponentName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UpdateComponent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_component_configuration(component_name, resource_group_name)
    update_component_configuration(component_name, resource_group_name, params::Dict{String,<:Any})

Updates the monitoring configurations for the component. The configuration input parameter
is an escaped JSON of the configuration and should match the schema of what is returned by
DescribeComponentConfigurationRecommendation.

# Arguments
- `component_name`: The name of the component.
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ComponentConfiguration"`: The configuration settings of the component. The value is the
  escaped JSON of the configuration. For more information about the JSON format, see Working
  with JSON. You can send a request to DescribeComponentConfigurationRecommendation to see
  the recommended configuration for a component. For the complete format of the component
  configuration file, see Component Configuration.
- `"Monitor"`: Indicates whether the application component is monitored.
- `"Tier"`: The tier of the application component. Supported tiers include DOT_NET_WORKER,
  DOT_NET_WEB, DOT_NET_CORE, SQL_SERVER, and DEFAULT.
"""
function update_component_configuration(
    ComponentName, ResourceGroupName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return application_insights(
        "UpdateComponentConfiguration",
        Dict{String,Any}(
            "ComponentName" => ComponentName, "ResourceGroupName" => ResourceGroupName
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_component_configuration(
    ComponentName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UpdateComponentConfiguration",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ComponentName" => ComponentName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_log_pattern(pattern_name, pattern_set_name, resource_group_name)
    update_log_pattern(pattern_name, pattern_set_name, resource_group_name, params::Dict{String,<:Any})

Adds a log pattern to a LogPatternSet.

# Arguments
- `pattern_name`: The name of the log pattern.
- `pattern_set_name`: The name of the log pattern set.
- `resource_group_name`: The name of the resource group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Pattern"`: The log pattern. The pattern must be DFA compatible. Patterns that utilize
  forward lookahead or backreference constructions are not supported.
- `"Rank"`: Rank of the log pattern. Must be a value between 1 and 1,000,000. The patterns
  are sorted by rank, so we recommend that you set your highest priority patterns with the
  lowest rank. A pattern of rank 1 will be the first to get matched to a log line. A pattern
  of rank 1,000,000 will be last to get matched. When you configure custom log patterns from
  the console, a Low severity pattern translates to a 750,000 rank. A Medium severity pattern
  translates to a 500,000 rank. And a High severity pattern translates to a 250,000 rank.
  Rank values less than 1 or greater than 1,000,000 are reserved for AWS-provided patterns.
"""
function update_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UpdateLogPattern",
        Dict{String,Any}(
            "PatternName" => PatternName,
            "PatternSetName" => PatternSetName,
            "ResourceGroupName" => ResourceGroupName,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_log_pattern(
    PatternName,
    PatternSetName,
    ResourceGroupName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return application_insights(
        "UpdateLogPattern",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "PatternName" => PatternName,
                    "PatternSetName" => PatternSetName,
                    "ResourceGroupName" => ResourceGroupName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

ext: jl


text:
int_rules_1_1_1_3 = @theory begin

    #= ::Subsection::Closed:: =#
    #= 1.1.1.3*(a+b*x)^m*(c+d*x)^n*(e+f*x)^p =#
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~(m') * (~c + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative((~a * ~c + ~b * ~d * (~x) ^ 2) ^ ~m * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (EqQ(~b * ~c + ~a * ~d, 0) && (EqQ(~n, ~m) && (IntegerQ(~m) && (NeQ(~m, -1) || EqQ(~e, 0) && (EqQ(~p, 1) || Not(IntegerQ(~p)))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~d * ~f * (~n + ~p + 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (NeQ(~n + ~p + 2, 0) && EqQ(~a * ~d * ~f * (~n + ~p + 2) - ~b * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)), 0))
    @apply_utils Antiderivative((~a + ~(b') * ~x) * (~(d') * ~x) ^ ~(n') * (~e + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) * (~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~d, ~e, ~f, ~n], ~x) && (IGtQ(~p, 0) && (EqQ(~b * ~e + ~a * ~f, 0) && Not(ILtQ(~n + ~p + 2, 0) && GtQ(~n + 2 * ~p, 0))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) * (~(d') * ~x) ^ ~(n') * (~e + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) * (~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~d, ~e, ~f, ~n], ~x) && (IGtQ(~p, 0) && ((NeQ(~n, -1) || EqQ(~p, 1)) && (NeQ(~b * ~e + ~a * ~f, 0) && ((Not(IntegerQ(~n)) || (LtQ(9 * ~p + 5 * ~n, 0) || (GeQ(~n + ~p + 1, 0) || GeQ(~n + ~p + 2, 0) && RationalQ(~a, ~b, ~d, ~e, ~f)))) && (NeQ(~n + ~p + 3, 0) || EqQ(~p, 1))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) * (~c + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n], ~x) && (NeQ(~b * ~c - ~a * ~d, 0) && (ILtQ(~n, 0) && ILtQ(~p, 0) || (EqQ(~p, 1) || IGtQ(~p, 0) && (Not(IntegerQ(~n)) || (LeQ(9 * ~p + 5 * (~n + 2), 0) || (GeQ(~n + ~p + 1, 0) || GeQ(~n + ~p + 2, 0) && RationalQ(~a, ~b, ~c, ~d, ~e, ~f)))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (-((~b * ~e - ~a * ~f)) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~f * (~p + 1) * (~c * ~f - ~d * ~e)) - ((~a * ~d * ~f * (~n + ~p + 2) - ~b * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1))) / (~f * (~p + 1) * (~c * ~f - ~d * ~e))) * Antiderivative((~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n], ~x) && (LtQ(~p, -1) && (Not(LtQ(~n, -1)) || (IntegerQ(~p) || Not(IntegerQ(~n) || Not(EqQ(~e, 0) || Not(EqQ(~c, 0) || LtQ(~p, ~n)))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (-((~b * ~e - ~a * ~f)) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~f * (~p + 1) * (~c * ~f - ~d * ~e)) - ((~a * ~d * ~f * (~n + ~p + 2) - ~b * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1))) / (~f * (~p + 1) * (~c * ~f - ~d * ~e))) * Antiderivative((~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ Simplify(~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (Not(RationalQ(~p)) && SumSimplerQ(~p, 1))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~d * ~f * (~n + ~p + 2)) + ((~a * ~d * ~f * (~n + ~p + 2) - ~b * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1))) / (~d * ~f * (~n + ~p + 2))) * Antiderivative((~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && NeQ(~n + ~p + 2, 0)
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ 2 * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1) * ((2 * ~a * ~d * ~f * (~n + ~p + 3) - ~b * (~d * ~e * (~n + 2) + ~c * ~f * (~p + 2))) + ~b * ~d * ~f * (~n + ~p + 2) * ~x)) / ((~d) ^ 2 * (~f) ^ 2 * (~n + ~p + 2) * (~n + ~p + 3)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (NeQ(~n + ~p + 2, 0) && (NeQ(~n + ~p + 3, 0) && EqQ(~d * ~f * (~n + ~p + 2) * ((~a) ^ 2 * ~d * ~f * (~n + ~p + 3) - ~b * (~b * ~c * ~e + ~a * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)))) - ~b * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)) * (~a * ~d * ~f * (~n + ~p + 4) - ~b * (~d * ~e * (~n + 2) + ~c * ~f * (~p + 2))), 0)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(f') * ~x) ^ ~(p'), ~x) => ~a * Antiderivative((~a + ~b * ~x) ^ ~n * (~c + ~d * ~x) ^ ~n * (~f * ~x) ^ ~p, ~x) + (~b / ~f) * Antiderivative((~a + ~b * ~x) ^ ~n * (~c + ~d * ~x) ^ ~n * (~f * ~x) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~f, ~m, ~n, ~p], ~x) && (EqQ(~b * ~c + ~a * ~d, 0) && (EqQ((~m - ~n) - 1, 0) && (Not(RationalQ(~p)) && (Not(IGtQ(~m, 0)) && NeQ(~m + ~n + ~p + 2, 0)))))
    @apply_utils Antiderivative((~(e') + ~(f') * ~x) ^ ~(p') / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x)), ~x) => Antiderivative(ExpandIntegrand((~e + ~f * ~x) ^ ~p / ((~a + ~b * ~x) * (~c + ~d * ~x)), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && IntegerQ(~p)
    @apply_utils Antiderivative((~(e') + ~(f') * ~x) ^ ~p / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x)), ~x) => ((~b * ~e - ~a * ~f) / (~b * ~c - ~a * ~d)) * Antiderivative((~e + ~f * ~x) ^ (~p - 1) / (~a + ~b * ~x), ~x) - ((~d * ~e - ~c * ~f) / (~b * ~c - ~a * ~d)) * Antiderivative((~e + ~f * ~x) ^ (~p - 1) / (~c + ~d * ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && LtQ(0, ~p, 1)
    @apply_utils Antiderivative((~(e') + ~(f') * ~x) ^ ~p / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x)), ~x) => (~f * (~e + ~f * ~x) ^ (~p - 1)) / (~b * ~d * (~p - 1)) + (1 / (~b * ~d)) * Antiderivative((((~b * ~d * (~e) ^ 2 - ~a * ~c * (~f) ^ 2) + ~f * ((2 * ~b * ~d * ~e - ~b * ~c * ~f) - ~a * ~d * ~f) * ~x) * (~e + ~f * ~x) ^ (~p - 2)) / ((~a + ~b * ~x) * (~c + ~d * ~x)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && GtQ(~p, 1)
    @apply_utils Antiderivative((~(e') + ~(f') * ~x) ^ ~p / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x)), ~x) => (~f * (~e + ~f * ~x) ^ (~p + 1)) / ((~p + 1) * (~b * ~e - ~a * ~f) * (~d * ~e - ~c * ~f)) + (1 / ((~b * ~e - ~a * ~f) * (~d * ~e - ~c * ~f))) * Antiderivative(((((~b * ~d * ~e - ~b * ~c * ~f) - ~a * ~d * ~f) - ~b * ~d * ~f * ~x) * (~e + ~f * ~x) ^ (~p + 1)) / ((~a + ~b * ~x) * (~c + ~d * ~x)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && LtQ(~p, -1)
    @apply_utils Antiderivative((~(e') + ~(f') * ~x) ^ ~p / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x)), ~x) => (~b / (~b * ~c - ~a * ~d)) * Antiderivative((~e + ~f * ~x) ^ ~p / (~a + ~b * ~x), ~x) - (~d / (~b * ~c - ~a * ~d)) * Antiderivative((~e + ~f * ~x) ^ ~p / (~c + ~d * ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~p], ~x) && Not(IntegerQ(~p))
    @apply_utils Antiderivative(((~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~p) / (~(a') + ~(b') * ~x), ~x) => Antiderivative(ExpandIntegrand((~e + ~f * ~x) ^ FractionalPart(~p), ((~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ IntegerPart(~p)) / (~a + ~b * ~x), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (IGtQ(~n, 0) && (LtQ(~p, -1) && FractionQ(~p)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) ^ ~m * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~p], ~x) && (IntegersQ(~m, ~n) && (IntegerQ(~p) || GtQ(~m, 0) && GeQ(~n, -1)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ 2 * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~b * ~c - ~a * ~d) ^ 2 * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~d) ^ 2 * (~d * ~e - ~c * ~f) * (~n + 1)) - (1 / ((~d) ^ 2 * (~d * ~e - ~c * ~f) * (~n + 1))) * Antiderivative((~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ ~p * Simp((((~a) ^ 2 * (~d) ^ 2 * ~f * (~n + ~p + 2) + (~b) ^ 2 * ~c * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1))) - 2 * ~a * ~b * ~d * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1))) - (~b) ^ 2 * ~d * (~d * ~e - ~c * ~f) * (~n + 1) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (LtQ(~n, -1) || EqQ(~n + ~p + 3, 0) && (NeQ(~n, -1) && (SumSimplerQ(~n, 1) || Not(SumSimplerQ(~p, 1)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ 2 * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~d * ~f * (~n + ~p + 3)) + (1 / (~d * ~f * (~n + ~p + 3))) * Antiderivative((~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp(((~a) ^ 2 * ~d * ~f * (~n + ~p + 3) - ~b * (~b * ~c * ~e + ~a * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)))) + ~b * (~a * ~d * ~f * (~n + ~p + 4) - ~b * (~d * ~e * (~n + 2) + ~c * ~f * (~p + 2))) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && NeQ(~n + ~p + 3, 0)
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) ^ (1 / 3) * (~(c') + ~(d') * ~x) ^ (2 / 3) * (~(e') + ~(f') * ~x)), ~x) => With([q = Rt((~d * ~e - ~c * ~f) / (~b * ~e - ~a * ~f), 3)], ((-(sqrt(3)) * q * atan(1 / sqrt(3) + (2 * q * (~a + ~b * ~x) ^ (1 / 3)) / (sqrt(3) * (~c + ~d * ~x) ^ (1 / 3)))) / (~d * ~e - ~c * ~f) + (q * log(~e + ~f * ~x)) / (2 * (~d * ~e - ~c * ~f))) - (3 * q * log(q * (~a + ~b * ~x) ^ (1 / 3) - (~c + ~d * ~x) ^ (1 / 3))) / (2 * (~d * ~e - ~c * ~f))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x)
    @apply_utils Antiderivative(1 / (sqrt(~(a') + ~(b') * ~x) * sqrt(~(c') + ~(d') * ~x) * (~(e') + ~(f') * ~x)), ~x) => ~b * ~f * Subst(Antiderivative(1 / (~d * (~b * ~e - ~a * ~f) ^ 2 + ~b * (~f) ^ 2 * (~x) ^ 2), ~x), ~x, sqrt(~a + ~b * ~x) * sqrt(~c + ~d * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && EqQ(2 * ~b * ~d * ~e - ~f * (~b * ~c + ~a * ~d), 0)
    @apply_utils Antiderivative(((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n) / (~(e') + ~(f') * ~x), ~x) => With([q = Denominator(~m)], q * Subst(Antiderivative((~x) ^ (q * (~m + 1) - 1) / ((~b * ~e - ~a * ~f) - (~d * ~e - ~c * ~f) * (~x) ^ q), ~x), ~x, (~a + ~b * ~x) ^ (1 / q) / (~c + ~d * ~x) ^ (1 / q))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (EqQ(~m + ~n + 1, 0) && (RationalQ(~n) && (LtQ(-1, ~m, 0) && SimplerQ(~a + ~b * ~x, ~c + ~d * ~x))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~e - ~a * ~f)) - ((~n * (~d * ~e - ~c * ~f)) / ((~m + 1) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n - 1) * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~p], ~x) && (EqQ(~m + ~n + ~p + 2, 0) && (GtQ(~n, 0) && ((SumSimplerQ(~m, 1) || Not(SumSimplerQ(~p, 1))) && NeQ(~m, -1))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (EqQ(Simplify(~m + ~n + ~p + 3), 0) && (EqQ(~a * ~d * ~f * (~m + 1) + ~b * ~c * ~f * (~n + 1) + ~b * ~d * ~e * (~p + 1), 0) && NeQ(~m, -1)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) + ((~a * ~d * ~f * (~m + 1) + ~b * ~c * ~f * (~n + 1) + ~b * ~d * ~e * (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (EqQ(Simplify(~m + ~n + ~p + 3), 0) && (LtQ(~m, -1) || SumSimplerQ(~m, 1)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p) / (~b * (~m + 1)) - (1 / (~b * (~m + 1))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n - 1) * (~e + ~f * ~x) ^ (~p - 1) * Simp(~d * ~e * ~n + ~c * ~f * ~p + ~d * ~f * (~n + ~p) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (LtQ(~m, -1) && (GtQ(~n, 0) && (GtQ(~p, 0) && (IntegersQ(2 * ~m, 2 * ~n, 2 * ~p) || (IntegersQ(~m, ~n + ~p) || IntegersQ(~p, ~m + ~n))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~b * ~c - ~a * ~d) * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n - 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~b * (~b * ~e - ~a * ~f) * (~m + 1)) + (1 / (~b * (~b * ~e - ~a * ~f) * (~m + 1))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n - 2) * (~e + ~f * ~x) ^ ~p * Simp(~a * ~d * (~d * ~e * (~n - 1) + ~c * ~f * (~p + 1)) + ~b * ~c * (~d * ~e * ((~m - ~n) + 2) - ~c * ~f * (~m + ~p + 2)) + ~d * (~a * ~d * ~f * (~n + ~p) + ~b * (~d * ~e * (~m + 1) - ~c * ~f * (~m + ~n + ~p + 1))) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~p], ~x) && (LtQ(~m, -1) && (GtQ(~n, 1) && (IntegersQ(2 * ~m, 2 * ~n, 2 * ~p) || (IntegersQ(~m, ~n + ~p) || IntegersQ(~p, ~m + ~n)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~e - ~a * ~f)) - (1 / ((~m + 1) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n - 1) * (~e + ~f * ~x) ^ ~p * Simp(~d * ~e * ~n + ~c * ~f * (~m + ~p + 2) + ~d * ~f * (~m + ~n + ~p + 2) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~p], ~x) && (LtQ(~m, -1) && (GtQ(~n, 0) && (IntegersQ(2 * ~m, 2 * ~n, 2 * ~p) || (IntegersQ(~m, ~n + ~p) || IntegersQ(~p, ~m + ~n)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m - 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~d * ~f * (~m + ~n + ~p + 1)) + (1 / (~d * ~f * (~m + ~n + ~p + 1))) * Antiderivative((~a + ~b * ~x) ^ (~m - 2) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp(((~a) ^ 2 * ~d * ~f * (~m + ~n + ~p + 1) - ~b * (~b * ~c * ~e * (~m - 1) + ~a * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)))) + ~b * (~a * ~d * ~f * (2 * ~m + ~n + ~p) - ~b * (~d * ~e * (~m + ~n) + ~c * ~f * (~m + ~p))) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (GtQ(~m, 1) && (NeQ(~m + ~n + ~p + 1, 0) && IntegerQ(~m)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => ((~a + ~b * ~x) ^ ~m * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ (~p + 1)) / (~f * (~m + ~n + ~p + 1)) - (1 / (~f * (~m + ~n + ~p + 1))) * Antiderivative((~a + ~b * ~x) ^ (~m - 1) * (~c + ~d * ~x) ^ (~n - 1) * (~e + ~f * ~x) ^ ~p * Simp(~c * ~m * (~b * ~e - ~a * ~f) + ~a * ~n * (~d * ~e - ~c * ~f) + (~d * ~m * (~b * ~e - ~a * ~f) + ~b * ~n * (~d * ~e - ~c * ~f)) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~p], ~x) && (GtQ(~m, 0) && (GtQ(~n, 0) && (NeQ(~m + ~n + ~p + 1, 0) && (IntegersQ(2 * ~m, 2 * ~n, 2 * ~p) || (IntegersQ(~m, ~n + ~p) || IntegersQ(~p, ~m + ~n))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m - 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / (~d * ~f * (~m + ~n + ~p + 1)) + (1 / (~d * ~f * (~m + ~n + ~p + 1))) * Antiderivative((~a + ~b * ~x) ^ (~m - 2) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp(((~a) ^ 2 * ~d * ~f * (~m + ~n + ~p + 1) - ~b * (~b * ~c * ~e * (~m - 1) + ~a * (~d * ~e * (~n + 1) + ~c * ~f * (~p + 1)))) + ~b * (~a * ~d * ~f * (2 * ~m + ~n + ~p) - ~b * (~d * ~e * (~m + ~n) + ~c * ~f * (~m + ~p))) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (GtQ(~m, 1) && (NeQ(~m + ~n + ~p + 1, 0) && IntegersQ(2 * ~m, 2 * ~n, 2 * ~p)))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) + (1 / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp((~a * ~d * ~f * (~m + 1) - ~b * (~d * ~e * (~m + ~n + 2) + ~c * ~f * (~m + ~p + 2))) - ~b * ~d * ~f * (~m + ~n + ~p + 3) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (ILtQ(~m, -1) && (IntegerQ(~n) || (IntegersQ(2 * ~n, 2 * ~p) || ILtQ(~m + ~n + ~p + 3, 0))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) + (1 / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp((~a * ~d * ~f * (~m + 1) - ~b * (~d * ~e * (~m + ~n + 2) + ~c * ~f * (~m + ~p + 2))) - ~b * ~d * ~f * (~m + ~n + ~p + 3) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (LtQ(~m, -1) && IntegersQ(2 * ~m, 2 * ~n, 2 * ~p))
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) * sqrt(~(c') + ~(d') * ~x) * (~(e') + ~(f') * ~x) ^ (1 / 4)), ~x) => -4 * Subst(Antiderivative((~x) ^ 2 / (((~b * ~e - ~a * ~f) - ~b * (~x) ^ 4) * sqrt((~c - (~d * ~e) / ~f) + (~d * (~x) ^ 4) / ~f)), ~x), ~x, (~e + ~f * ~x) ^ (1 / 4)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && GtQ(-(~f) / (~d * ~e - ~c * ~f), 0)
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) * sqrt(~(c') + ~(d') * ~x) * (~(e') + ~(f') * ~x) ^ (1 / 4)), ~x) => (sqrt((-(~f) * (~c + ~d * ~x)) / (~d * ~e - ~c * ~f)) / sqrt(~c + ~d * ~x)) * Antiderivative(1 / ((~a + ~b * ~x) * sqrt((-(~c) * ~f) / (~d * ~e - ~c * ~f) - (~d * ~f * ~x) / (~d * ~e - ~c * ~f)) * (~e + ~f * ~x) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && Not(GtQ(-(~f) / (~d * ~e - ~c * ~f), 0))
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) * sqrt(~(c') + ~(d') * ~x) * (~(e') + ~(f') * ~x) ^ (3 / 4)), ~x) => -4 * Subst(Antiderivative(1 / (((~b * ~e - ~a * ~f) - ~b * (~x) ^ 4) * sqrt((~c - (~d * ~e) / ~f) + (~d * (~x) ^ 4) / ~f)), ~x), ~x, (~e + ~f * ~x) ^ (1 / 4)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && GtQ(-(~f) / (~d * ~e - ~c * ~f), 0)
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) * sqrt(~(c') + ~(d') * ~x) * (~(e') + ~(f') * ~x) ^ (3 / 4)), ~x) => (sqrt((-(~f) * (~c + ~d * ~x)) / (~d * ~e - ~c * ~f)) / sqrt(~c + ~d * ~x)) * Antiderivative(1 / ((~a + ~b * ~x) * sqrt((-(~c) * ~f) / (~d * ~e - ~c * ~f) - (~d * ~f * ~x) / (~d * ~e - ~c * ~f)) * (~e + ~f * ~x) ^ (3 / 4)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && Not(GtQ(-(~f) / (~d * ~e - ~c * ~f), 0))
    @apply_utils Antiderivative(sqrt(~e + ~(f') * ~x) / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x)), ~x) => ((2 * sqrt(~e)) / ~b) * Rt(-(~b) / ~d, 2) * Elliptic.E(asin(sqrt(~b * ~x) / (sqrt(~c) * Rt(-(~b) / ~d, 2))), (~c * ~f) / (~d * ~e)) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && (NeQ(~d * ~e - ~c * ~f, 0) && (GtQ(~c, 0) && (GtQ(~e, 0) && Not(LtQ(-(~b) / ~d, 0)))))
    @apply_utils Antiderivative(sqrt(~e + ~(f') * ~x) / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x)), ~x) => (sqrt(-(~b) * ~x) / sqrt(~b * ~x)) * Antiderivative(sqrt(~e + ~f * ~x) / (sqrt(-(~b) * ~x) * sqrt(~c + ~d * ~x)), ~x) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && (NeQ(~d * ~e - ~c * ~f, 0) && (GtQ(~c, 0) && (GtQ(~e, 0) && LtQ(-(~b) / ~d, 0))))
    @apply_utils Antiderivative(sqrt(~e + ~(f') * ~x) / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x)), ~x) => ((sqrt(~e + ~f * ~x) * sqrt(1 + (~d * ~x) / ~c)) / (sqrt(~c + ~d * ~x) * sqrt(1 + (~f * ~x) / ~e))) * Antiderivative(sqrt(1 + (~f * ~x) / ~e) / (sqrt(~b * ~x) * sqrt(1 + (~d * ~x) / ~c)), ~x) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && (NeQ(~d * ~e - ~c * ~f, 0) && Not(GtQ(~c, 0) && GtQ(~e, 0)))
    #= Antiderivative(sqrt((~e')+(~f')*(~x))/(sqrt((~a)+(~b')*(~x))*sqrt((~c)+(~d')*(~x))),~x) :=   f/b*Antiderivative(sqrt(a+b*x)/(sqrt(c+d*x)*sqrt(e+f*x)),x) - f/b*Antiderivative(1/(sqrt(a+b*x)*sqrt(c+d*x)*sqrt(e+f*x)),x) <--  FreeQ([a,b,c,d,e,f],x) && EqQ(b*e-f*(a-1),0) =#
    #= Antiderivative(sqrt((~e')+(~f')*(~x))/(sqrt((~a)+(~b')*(~x))*sqrt((~c)+(~d')*(~x))),~x) :=   2/b*Rt(-(b*c-a*d)/d,2)*sqrt((b*e-a*f)/(b*c-a*d))* Elliptic.E(asin(sqrt(a+b*x)/Rt(-(b*c-a*d)/d,2)),f*(b*c-a*d)/(d*( b*e-a*f))) <-- FreeQ([a,b,c,d,e,f],x) && GtQ(b/(b*c-a*d),0) &&  GtQ(b/(b*e-a*f),0) && Not(LtQ(-(b*c-a*d)/d,0)) && Not(SimplerQ(c+d*x,a+b*x) && GtQ(-d/(b*c-a*d),0) &&  GtQ(d/(d*e-c*f),0) && Not(LtQ((b*c-a*d)/b,0))) =#
    @apply_utils Antiderivative(sqrt(~(e') + ~(f') * ~x) / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x)), ~x) => (2 / ~b) * Rt(-((~b * ~e - ~a * ~f)) / ~d, 2) * Elliptic.E(asin(sqrt(~a + ~b * ~x) / Rt(-((~b * ~c - ~a * ~d)) / ~d, 2)), (~f * (~b * ~c - ~a * ~d)) / (~d * (~b * ~e - ~a * ~f))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (GtQ(~b / (~b * ~c - ~a * ~d), 0) && (GtQ(~b / (~b * ~e - ~a * ~f), 0) && (Not(LtQ(-((~b * ~c - ~a * ~d)) / ~d, 0)) && Not(SimplerQ(~c + ~d * ~x, ~a + ~b * ~x) && (GtQ(-(~d) / (~b * ~c - ~a * ~d), 0) && (GtQ(~d / (~d * ~e - ~c * ~f), 0) && Not(LtQ((~b * ~c - ~a * ~d) / ~b, 0))))))))
    @apply_utils Antiderivative(sqrt(~(e') + ~(f') * ~x) / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x)), ~x) => ((sqrt(~e + ~f * ~x) * sqrt((~b * (~c + ~d * ~x)) / (~b * ~c - ~a * ~d))) / (sqrt(~c + ~d * ~x) * sqrt((~b * (~e + ~f * ~x)) / (~b * ~e - ~a * ~f)))) * Antiderivative(sqrt((~b * ~e) / (~b * ~e - ~a * ~f) + (~b * ~f * ~x) / (~b * ~e - ~a * ~f)) / (sqrt(~a + ~b * ~x) * sqrt((~b * ~c) / (~b * ~c - ~a * ~d) + (~b * ~d * ~x) / (~b * ~c - ~a * ~d))), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (Not(GtQ(~b / (~b * ~c - ~a * ~d), 0) && GtQ(~b / (~b * ~e - ~a * ~f), 0)) && Not(LtQ(-((~b * ~c - ~a * ~d)) / ~d, 0)))
    @apply_utils Antiderivative(1 / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => (2 / (~b * sqrt(~e))) * Rt(-(~b) / ~d, 2) * Elliptic.F(asin(sqrt(~b * ~x) / (sqrt(~c) * Rt(-(~b) / ~d, 2))), (~c * ~f) / (~d * ~e)) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && (GtQ(~c, 0) && (GtQ(~e, 0) && (GtQ(-(~b) / ~d, 0) || LtQ(-(~b) / ~f, 0))))
    @apply_utils Antiderivative(1 / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => (2 / (~b * sqrt(~e))) * Rt(-(~b) / ~d, 2) * Elliptic.F(asin(sqrt(~b * ~x) / (sqrt(~c) * Rt(-(~b) / ~d, 2))), (~c * ~f) / (~d * ~e)) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && (GtQ(~c, 0) && (GtQ(~e, 0) && (PosQ(-(~b) / ~d) || NegQ(-(~b) / ~f))))
    @apply_utils Antiderivative(1 / (sqrt(~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => ((sqrt(1 + (~d * ~x) / ~c) * sqrt(1 + (~f * ~x) / ~e)) / (sqrt(~c + ~d * ~x) * sqrt(~e + ~f * ~x))) * Antiderivative(1 / (sqrt(~b * ~x) * sqrt(1 + (~d * ~x) / ~c) * sqrt(1 + (~f * ~x) / ~e)), ~x) <-- FreeQ([~b, ~c, ~d, ~e, ~f], ~x) && Not(GtQ(~c, 0) && GtQ(~e, 0))
    @apply_utils Antiderivative(1 / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => ((-2 * sqrt(~d / ~f)) / (~d * Rt(-((~b * ~e - ~a * ~f)) / ~f, 2))) * Elliptic.F(asin(Rt(-((~b * ~e - ~a * ~f)) / ~f, 2) / sqrt(~a + ~b * ~x)), (~f * (~b * ~c - ~a * ~d)) / (~d * (~b * ~e - ~a * ~f))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (GtQ(~d / ~b, 0) && (GtQ(~f / ~b, 0) && (LeQ(~c, (~a * ~d) / ~b) && LeQ(~e, (~a * ~f) / ~b))))
    #= Antiderivative(1/(sqrt((~a)+(~b')*(~x))*sqrt((~c)+(~d')*(~x))*sqrt((~e)+(~f')*(~x))),~x) :=   -2*sqrt(c+d*x)*sqrt(b*(e+f*x)/(f*(a+b*x)))/(d*Rt(-(b*e-a*f)/f,2)* sqrt(e+f*x)*sqrt(b*(c+d*x)/(d*(a+b*x))))* Elliptic.F(asin(Rt(-(b*e-a*f)/f,2)/sqrt(a+b*x)),f*(b*c-a*d)/(d*( b*e-a*f))) <-- FreeQ([a,b,c,d,e,f],x) && PosQ(-(b*e-a*f)/f) && #=  (LtQ(-a/b,-c/d,-e/f) || GtQ(-a/b,-c/d,-e/f)) =#  Not(SimplerQ(c+d*x,a+b*x) && (PosQ((-d*e+c*f)/f) ||  PosQ((b*e-a*f)/b))) && Not(SimplerQ(e+f*x,a+b*x) && (PosQ((b*e-a*f)/b) ||  PosQ((b*c-a*d)/b))) =#
    @apply_utils Antiderivative(1 / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => ((2 * Rt(-(~b) / ~d, 2)) / (~b * sqrt((~b * ~e - ~a * ~f) / ~b))) * Elliptic.F(asin(sqrt(~a + ~b * ~x) / (Rt(-(~b) / ~d, 2) * sqrt((~b * ~c - ~a * ~d) / ~b))), (~f * (~b * ~c - ~a * ~d)) / (~d * (~b * ~e - ~a * ~f))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (GtQ((~b * ~c - ~a * ~d) / ~b, 0) && (GtQ((~b * ~e - ~a * ~f) / ~b, 0) && (PosQ(-(~b) / ~d) && (Not(SimplerQ(~c + ~d * ~x, ~a + ~b * ~x) && (GtQ((~d * ~e - ~c * ~f) / ~d, 0) && GtQ(-(~d) / ~b, 0))) && (Not(SimplerQ(~c + ~d * ~x, ~a + ~b * ~x) && (GtQ((-(~b) * ~e + ~a * ~f) / ~f, 0) && GtQ(-(~f) / ~b, 0))) && Not(SimplerQ(~e + ~f * ~x, ~a + ~b * ~x) && (GtQ((-(~d) * ~e + ~c * ~f) / ~f, 0) && (GtQ((-(~b) * ~e + ~a * ~f) / ~f, 0) && (PosQ(-(~f) / ~d) || PosQ(-(~f) / ~b))))))))))
    @apply_utils Antiderivative(1 / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => ((2 * Rt(-(~b) / ~d, 2)) / (~b * sqrt((~b * ~e - ~a * ~f) / ~b))) * Elliptic.F(asin(sqrt(~a + ~b * ~x) / (Rt(-(~b) / ~d, 2) * sqrt((~b * ~c - ~a * ~d) / ~b))), (~f * (~b * ~c - ~a * ~d)) / (~d * (~b * ~e - ~a * ~f))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (GtQ(~b / (~b * ~c - ~a * ~d), 0) && (GtQ(~b / (~b * ~e - ~a * ~f), 0) && (SimplerQ(~a + ~b * ~x, ~c + ~d * ~x) && (SimplerQ(~a + ~b * ~x, ~e + ~f * ~x) && (PosQ(-((~b * ~c - ~a * ~d)) / ~d) || NegQ(-((~b * ~e - ~a * ~f)) / ~f))))))
    @apply_utils Antiderivative(1 / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => (sqrt((~b * (~c + ~d * ~x)) / (~b * ~c - ~a * ~d)) / sqrt(~c + ~d * ~x)) * Antiderivative(1 / (sqrt(~a + ~b * ~x) * sqrt((~b * ~c) / (~b * ~c - ~a * ~d) + (~b * ~d * ~x) / (~b * ~c - ~a * ~d)) * sqrt(~e + ~f * ~x)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (Not(GtQ((~b * ~c - ~a * ~d) / ~b, 0)) && (SimplerQ(~a + ~b * ~x, ~c + ~d * ~x) && SimplerQ(~a + ~b * ~x, ~e + ~f * ~x)))
    @apply_utils Antiderivative(1 / (sqrt(~a + ~(b') * ~x) * sqrt(~c + ~(d') * ~x) * sqrt(~e + ~(f') * ~x)), ~x) => (sqrt((~b * (~e + ~f * ~x)) / (~b * ~e - ~a * ~f)) / sqrt(~e + ~f * ~x)) * Antiderivative(1 / (sqrt(~a + ~b * ~x) * sqrt(~c + ~d * ~x) * sqrt((~b * ~e) / (~b * ~e - ~a * ~f) + (~b * ~f * ~x) / (~b * ~e - ~a * ~f))), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && Not(GtQ((~b * ~e - ~a * ~f) / ~b, 0))
    @apply_utils Antiderivative(1 / ((~(a') + ~(b') * ~x) * (~(c') + ~(d') * ~x) ^ (1 / 3) * (~(e') + ~(f') * ~x) ^ (1 / 3)), ~x) => With([q = Rt((~b * (~b * ~e - ~a * ~f)) / (~b * ~c - ~a * ~d) ^ 2, 3)], (-(log(~a + ~b * ~x)) / (2 * q * (~b * ~c - ~a * ~d)) - (sqrt(3) * atan(1 / sqrt(3) + (2 * q * (~c + ~d * ~x) ^ (2 / 3)) / (sqrt(3) * (~e + ~f * ~x) ^ (1 / 3)))) / (2 * q * (~b * ~c - ~a * ~d))) + (3 * log(q * (~c + ~d * ~x) ^ (2 / 3) - (~e + ~f * ~x) ^ (1 / 3))) / (4 * q * (~b * ~c - ~a * ~d))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && EqQ((2 * ~b * ~d * ~e - ~b * ~c * ~f) - ~a * ~d * ~f, 0)
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m / ((~(c') + ~(d') * ~x) ^ (1 / 3) * (~(e') + ~(f') * ~x) ^ (1 / 3)), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (2 / 3) * (~e + ~f * ~x) ^ (2 / 3)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) + (~f / (6 * (~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f))) * Antiderivative(((~a + ~b * ~x) ^ (~m + 1) * ((~a * ~d * (3 * ~m + 1) - 3 * ~b * ~c * (3 * ~m + 5)) - 2 * ~b * ~d * (3 * ~m + 7) * ~x)) / ((~c + ~d * ~x) ^ (1 / 3) * (~e + ~f * ~x) ^ (1 / 3)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f], ~x) && (EqQ((2 * ~b * ~d * ~e - ~b * ~c * ~f) - ~a * ~d * ~f, 0) && ILtQ(~m, -1))
    #= Antiderivative(((~a')+(~b')*(~x))^(~m')*((~c')+(~d')*(~x))^(~n')*((~f')*(~x))^(~p'),~x) :=  Simp((a+b*x)^m*(c+d*x)^m/(a*c+b*d*x^2)^m)*Antiderivative((a*c+b*d*x^2)^m*(f*x)^p, x) <-- FreeQ([a,b,c,d,f,m,n,p],x) && EqQ(b*c+a*d,0) && EqQ(n,m) =#
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(f') * ~x) ^ ~(p'), ~x) => Antiderivative((~a * ~c + ~b * ~d * (~x) ^ 2) ^ ~m * (~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~f, ~m, ~n, ~p], ~x) && (EqQ(~b * ~c + ~a * ~d, 0) && (EqQ(~n, ~m) && (GtQ(~a, 0) && GtQ(~c, 0))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(f') * ~x) ^ ~(p'), ~x) => (((~a + ~b * ~x) ^ FracPart(~m) * (~c + ~d * ~x) ^ FracPart(~m)) / (~a * ~c + ~b * ~d * (~x) ^ 2) ^ FracPart(~m)) * Antiderivative((~a * ~c + ~b * ~d * (~x) ^ 2) ^ ~m * (~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~f, ~m, ~n, ~p], ~x) && (EqQ(~b * ~c + ~a * ~d, 0) && EqQ(~n, ~m))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) ^ ~m * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~n, ~p], ~x) && (IGtQ(~m, 0) || ILtQ(~m, 0) && ILtQ(~n, 0))
    @apply_utils Antiderivative((~(e') * ~x) ^ ~p * (~a + ~(b') * ~x) ^ ~m * (~c + ~(d') * ~x) ^ ~n, ~x) => With([k = Denominator(~p)], (k / ~e) * Subst(Antiderivative((~x) ^ (k * (~p + 1) - 1) * (~a + (~b * (~x) ^ k) / ~e) ^ ~m * (~c + (~d * (~x) ^ k) / ~e) ^ ~n, ~x), ~x, (~e * ~x) ^ (1 / k))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~n], ~x) && (NeQ(~b * ~c - ~a * ~d, 0) && (FractionQ(~p) && IntegerQ(~m)))
    @apply_utils Antiderivative(((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n) / (~(e') + ~(f') * ~x) ^ 2, ~x) => ((~b * ~d) / (~f) ^ 2) * Antiderivative((~a + ~b * ~x) ^ (~m - 1) * (~c + ~d * ~x) ^ (~n - 1), ~x) + (((~b * ~e - ~a * ~f) * (~d * ~e - ~c * ~f)) / (~f) ^ 2) * Antiderivative(((~a + ~b * ~x) ^ (~m - 1) * (~c + ~d * ~x) ^ (~n - 1)) / (~e + ~f * ~x) ^ 2, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (IGtQ(~m + ~n, 0) && EqQ(2 * ~b * ~d * ~e - ~f * (~b * ~c + ~a * ~d), 0))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ((~f) ^ (~p - 1) / (~d) ^ ~p) * Antiderivative(((~a + ~b * ~x) ^ ~m * ((~d * ~e * ~p - ~c * ~f * (~p - 1)) + ~d * ~f * ~x)) / (~c + ~d * ~x) ^ (~m + 1), ~x) + (~f) ^ (~p - 1) * Antiderivative((((~a + ~b * ~x) ^ ~m * (~e + ~f * ~x) ^ ~p) / (~c + ~d * ~x) ^ (~m + 1)) * ExpandToSum((~f) ^ (-(~p) + 1) * (~c + ~d * ~x) ^ (-(~p) + 1) - ((~d * ~e * ~p - ~c * ~f * (~p - 1)) + ~d * ~f * ~x) / ((~d) ^ ~p * (~e + ~f * ~x) ^ ~p), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (EqQ(~m + ~n + ~p, 0) && (ILtQ(~p, 0) && (LtQ(~m, 0) || (SumSimplerQ(~m, 1) || Not(LtQ(~n, 0) || SumSimplerQ(~n, 1))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ~b * (~d) ^ (~m + ~n) * (~f) ^ ~p * Antiderivative((~a + ~b * ~x) ^ (~m - 1) / (~c + ~d * ~x) ^ ~m, ~x) + Antiderivative((((~a + ~b * ~x) ^ (~m - 1) * (~e + ~f * ~x) ^ ~p) / (~c + ~d * ~x) ^ ~m) * ExpandToSum((~a + ~b * ~x) * (~c + ~d * ~x) ^ (-(~p) - 1) - (~b * (~d) ^ (-(~p) - 1) * (~f) ^ ~p) / (~e + ~f * ~x) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (EqQ(~m + ~n + ~p + 1, 0) && (ILtQ(~p, 0) && (GtQ(~m, 0) || (SumSimplerQ(~m, -1) || Not(GtQ(~n, 0) || SumSimplerQ(~n, -1))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~p, ~x) => (((~b * ~c - ~a * ~d) ^ ~n * (~a + ~b * ~x) ^ (~m + 1)) / ((~m + 1) * (~b * ~e - ~a * ~f) ^ (~n + 1) * (~e + ~f * ~x) ^ (~m + 1))) * HypergeometricFunctions._₂F₁(~m + 1, -(~n), ~m + 2, (-((~d * ~e - ~c * ~f)) * (~a + ~b * ~x)) / ((~b * ~c - ~a * ~d) * (~e + ~f * ~x))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~p], ~x) && (EqQ(~m + ~n + ~p + 2, 0) && (ILtQ(~n, 0) && ((SumSimplerQ(~m, 1) || Not(SumSimplerQ(~p, 1))) && Not(ILtQ(~m, 0)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => (((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ (~p + 1)) / ((~b * ~e - ~a * ~f) * (~m + 1))) * (((~b * ~e - ~a * ~f) * (~c + ~d * ~x)) / ((~b * ~c - ~a * ~d) * (~e + ~f * ~x))) ^ -(~n) * HypergeometricFunctions._₂F₁(~m + 1, -(~n), ~m + 2, (-((~d * ~e - ~c * ~f)) * (~a + ~b * ~x)) / ((~b * ~c - ~a * ~d) * (~e + ~f * ~x))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (EqQ(~m + ~n + ~p + 2, 0) && Not(IntegerQ(~n)))
    @apply_utils Antiderivative(((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n) / (~(e') + ~(f') * ~x), ~x) => ((~c * ~f - ~d * ~e) ^ (~m + ~n + 1) / (~f) ^ (~m + ~n + 1)) * Antiderivative((~a + ~b * ~x) ^ ~m / ((~c + ~d * ~x) ^ (~m + 1) * (~e + ~f * ~x)), ~x) + (1 / (~f) ^ (~m + ~n + 1)) * Antiderivative(((~a + ~b * ~x) ^ ~m / (~c + ~d * ~x) ^ (~m + 1)) * ExpandToSum(((~f) ^ (~m + ~n + 1) * (~c + ~d * ~x) ^ (~m + ~n + 1) - (~c * ~f - ~d * ~e) ^ (~m + ~n + 1)) / (~e + ~f * ~x), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (IGtQ(~m + ~n + 1, 0) && (LtQ(~m, 0) || (SumSimplerQ(~m, 1) || Not(LtQ(~n, 0) || SumSimplerQ(~n, 1)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~(n') * (~(e') + ~(f') * ~x) ^ ~(p'), ~x) => (~b * (~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ (~n + 1) * (~e + ~f * ~x) ^ (~p + 1)) / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f)) + (1 / ((~m + 1) * (~b * ~c - ~a * ~d) * (~b * ~e - ~a * ~f))) * Antiderivative((~a + ~b * ~x) ^ (~m + 1) * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p * Simp((~a * ~d * ~f * (~m + 1) - ~b * (~d * ~e * (~m + ~n + 2) + ~c * ~f * (~m + ~p + 2))) - ~b * ~d * ~f * (~m + ~n + ~p + 3) * ~x, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (ILtQ(~m + ~n + ~p + 2, 0) && (NeQ(~m, -1) && (SumSimplerQ(~m, 1) || Not(SumSimplerQ(~n, 1)) && Not(SumSimplerQ(~p, 1)))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x) ^ ~(m') * (~(c') + ~(d') * ~x) ^ ~(n') * (~(f') * ~x) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~a + ~b * ~x) ^ ~n * (~c + ~d * ~x) ^ ~n * (~f * ~x) ^ ~p, (~a + ~b * ~x) ^ (~m - ~n), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~f, ~m, ~n, ~p], ~x) && (EqQ(~b * ~c + ~a * ~d, 0) && (IGtQ(~m - ~n, 0) && NeQ(~m + ~n + ~p + 2, 0)))
    @apply_utils Antiderivative((~(b') * ~x) ^ ~m * (~c + ~(d') * ~x) ^ ~n * (~e + ~(f') * ~x) ^ ~p, ~x) => (((~c) ^ ~n * (~e) ^ ~p * (~b * ~x) ^ (~m + 1)) / (~b * (~m + 1))) * AppellF1(~m + 1, -(~n), -(~p), ~m + 2, (-(~d) * ~x) / ~c, (-(~f) * ~x) / ~e) <-- FreeQ([~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (GtQ(~c, 0) && (IntegerQ(~p) || GtQ(~e, 0)))))
    @apply_utils Antiderivative((~(b') * ~x) ^ ~m * (~c + ~(d') * ~x) ^ ~n * (~e + ~(f') * ~x) ^ ~p, ~x) => ((~c + ~d * ~x) ^ (~n + 1) / (~d * (~n + 1) * (-(~d) / (~b * ~c)) ^ ~m * (~d / (~d * ~e - ~c * ~f)) ^ ~p)) * AppellF1(~n + 1, -(~m), -(~p), ~n + 2, 1 + (~d * ~x) / ~c, (-(~f) * (~c + ~d * ~x)) / (~d * ~e - ~c * ~f)) <-- FreeQ([~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (GtQ(-(~d) / (~b * ~c), 0) && (IntegerQ(~p) || GtQ(~d / (~d * ~e - ~c * ~f), 0)))))
    @apply_utils Antiderivative((~(b') * ~x) ^ ~m * (~c + ~(d') * ~x) ^ ~n * (~e + ~(f') * ~x) ^ ~p, ~x) => (((~c) ^ IntPart(~n) * (~c + ~d * ~x) ^ FracPart(~n)) / (1 + (~d * ~x) / ~c) ^ FracPart(~n)) * Antiderivative((~b * ~x) ^ ~m * (1 + (~d * ~x) / ~c) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && Not(GtQ(~c, 0))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => (((~b * ~e - ~a * ~f) ^ ~p * (~a + ~b * ~x) ^ (~m + 1)) / ((~b) ^ (~p + 1) * (~m + 1) * (~b / (~b * ~c - ~a * ~d)) ^ ~n)) * AppellF1(~m + 1, -(~n), -(~p), ~m + 2, (-(~d) * (~a + ~b * ~x)) / (~b * ~c - ~a * ~d), (-(~f) * (~a + ~b * ~x)) / (~b * ~e - ~a * ~f)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (IntegerQ(~p) && (GtQ(~b / (~b * ~c - ~a * ~d), 0) && Not(GtQ(~d / (~d * ~a - ~c * ~b), 0) && SimplerQ(~c + ~d * ~x, ~a + ~b * ~x))))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ((~c + ~d * ~x) ^ FracPart(~n) / ((~b / (~b * ~c - ~a * ~d)) ^ IntPart(~n) * ((~b * (~c + ~d * ~x)) / (~b * ~c - ~a * ~d)) ^ FracPart(~n))) * Antiderivative((~a + ~b * ~x) ^ ~m * ((~b * ~c) / (~b * ~c - ~a * ~d) + (~b * ~d * ~x) / (~b * ~c - ~a * ~d)) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (IntegerQ(~p) && (Not(GtQ(~b / (~b * ~c - ~a * ~d), 0)) && Not(SimplerQ(~c + ~d * ~x, ~a + ~b * ~x))))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ((~a + ~b * ~x) ^ (~m + 1) / (~b * (~m + 1) * (~b / (~b * ~c - ~a * ~d)) ^ ~n * (~b / (~b * ~e - ~a * ~f)) ^ ~p)) * AppellF1(~m + 1, -(~n), -(~p), ~m + 2, (-(~d) * (~a + ~b * ~x)) / (~b * ~c - ~a * ~d), (-(~f) * (~a + ~b * ~x)) / (~b * ~e - ~a * ~f)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (Not(IntegerQ(~p)) && (GtQ(~b / (~b * ~c - ~a * ~d), 0) && (GtQ(~b / (~b * ~e - ~a * ~f), 0) && (Not(GtQ(~d / (~d * ~a - ~c * ~b), 0) && (GtQ(~d / (~d * ~e - ~c * ~f), 0) && SimplerQ(~c + ~d * ~x, ~a + ~b * ~x))) && Not(GtQ(~f / (~f * ~a - ~e * ~b), 0) && (GtQ(~f / (~f * ~c - ~e * ~d), 0) && SimplerQ(~e + ~f * ~x, ~a + ~b * ~x)))))))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ((~e + ~f * ~x) ^ FracPart(~p) / ((~b / (~b * ~e - ~a * ~f)) ^ IntPart(~p) * ((~b * (~e + ~f * ~x)) / (~b * ~e - ~a * ~f)) ^ FracPart(~p))) * Antiderivative((~a + ~b * ~x) ^ ~m * (~c + ~d * ~x) ^ ~n * ((~b * ~e) / (~b * ~e - ~a * ~f) + (~b * ~f * ~x) / (~b * ~e - ~a * ~f)) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (Not(IntegerQ(~p)) && (GtQ(~b / (~b * ~c - ~a * ~d), 0) && Not(GtQ(~b / (~b * ~e - ~a * ~f), 0))))))
    @apply_utils Antiderivative((~a + ~(b') * ~x) ^ ~m * (~(c') + ~(d') * ~x) ^ ~n * (~(e') + ~(f') * ~x) ^ ~p, ~x) => ((~c + ~d * ~x) ^ FracPart(~n) / ((~b / (~b * ~c - ~a * ~d)) ^ IntPart(~n) * ((~b * (~c + ~d * ~x)) / (~b * ~c - ~a * ~d)) ^ FracPart(~n))) * Antiderivative((~a + ~b * ~x) ^ ~m * ((~b * ~c) / (~b * ~c - ~a * ~d) + (~b * ~d * ~x) / (~b * ~c - ~a * ~d)) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (Not(IntegerQ(~m)) && (Not(IntegerQ(~n)) && (Not(IntegerQ(~p)) && (Not(GtQ(~b / (~b * ~c - ~a * ~d), 0)) && (Not(SimplerQ(~c + ~d * ~x, ~a + ~b * ~x)) && Not(SimplerQ(~e + ~f * ~x, ~a + ~b * ~x)))))))
    @apply_utils Antiderivative((~(a') + ~(b') * ~u) ^ ~(m') * (~(c') + ~(d') * ~u) ^ ~(n') * (~e + ~(f') * ~u) ^ ~(p'), ~x) => (1 / Coefficient(~u, ~x, 1)) * Subst(Antiderivative((~a + ~b * ~x) ^ ~m * (~c + ~d * ~x) ^ ~n * (~e + ~f * ~x) ^ ~p, ~x), ~x, ~u) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~f, ~m, ~n, ~p], ~x) && (LinearQ(~u, ~x) && NeQ(~u, ~x))
end

max_stars_repo_path: src/rules/1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.3 (a+b x)^m (c+d x)^n (e+f x)^p.jl


text:
# Throwaway timings (compiling)
@time time_weighted_median(data, weights, num_tests)

# Performance tests
num_points = int(1e6)
num_sets = 50
data_range = 10000
wt_range = 100

println(num_sets, " data sets (", num_points, " data points each)")

# weights: [0, wt_range)
wt = @array(:($wt_range * rand($num_points)), num_sets)

# data:
#   [-data_range/2, data_range/2),
#   [0, data_range),
#   [-data_range, 0)
data_expr = (:($data_range * (rand($num_points) - 0.5)),
             :($data_range * rand($num_points)),
             :(-$data_range * rand($num_points)))

timer(@array(data_expr[1], num_sets), wt)
timer(@array(data_expr[2], num_sets), wt)
timer(@array(data_expr[3], num_sets), wt)


text:
#################################################
# Extensions to Flux's update! function
#################################################

import Flux.Optimise: update!

Optimiser = Flux.Optimise.AbstractOptimiser

TupleTypes = Union{Tuple,NamedTuple}

function update!(opt::Optimiser, params::Any, grads::Nothing)
    return
end

function update!(opt::Optimiser, params::Any, grads::TupleTypes)
    for pname in propertynames(grads)
        g = getproperty(grads,pname)
        if g != nothing
            update!(opt, getproperty(params, pname), g)
        end
    end
end

#################################################
# Extensions to Functors' fmap functions
#################################################
import Functors: fmap, fmapstructure

# I don't see why Functors doesn't handle
# this case by default...
fmap(f, t::Tuple{}) = ()
fmapstructure(f, t::Tuple{}) = ()

###################################################
# Other arithmetic operations for gradient updates
###################################################

function binop!(op, a::Any, b::Nothing)
    return
end

function binop!(op, a::AbstractArray, b::AbstractArray)
    a .= op(a,b)
end

function binop!(op, a::Any, b::TupleTypes)
    for pname in propertynames(b)
        v = getproperty(b, pname)
        if v != nothing
            u = getproperty(a, pname)
            binop!(op, u, v)
        end
    end
end

####################################################
# Extract a whole tree of trainable parameters
####################################################

function rec_trainable(obj::AbstractArray)
    return obj
end

function rec_trainable(obj::Tuple)
    return map(rec_trainable, obj)
end

function rec_trainable(obj)
    trn = Flux.trainable(obj)
    return map(rec_trainable, trn)
end

###################################################
# Define a custom `zero` function
###################################################

tozero(x::Tuple{}) = ()
tozero(x::Nothing) = nothing
tozero(x) = zero(x)

max_stars_repo_name: dpmerrell/BatchMatFac

max_issues_repo_name: dpmerrell/BatchMatFac

max_forks_repo_name: dpmerrell/BatchMatFac


text:
include("lp.jl")
include("sdp.jl")
include("MOI_wrapper.jl")


text:
# Command: Dismiss Alert
"""
    dismiss(session::Session)::Nothing

Dismisses the currently displayed alert dialog.

!!! note

    This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
"""
function dismiss(session::Session)
    @unpack addr, id = session
    response = HTTP.post(
        "$addr/session/$id/dismiss_alert",
        [("Content-Type" => "application/json; charset=utf-8")],
    )
    @assert response.status == 200
end


text:
using Test, MerkleTrees

@testset "Merkle" begin
    @testset "Parent" begin
        tx_hash0 = hex2bytes("c117ea8ec828342f4dfb0ad6bd140e03a50720ece40169ee38bdc15d9eb64cf5")
        tx_hash1 = hex2bytes("c131474164b412e3406696da1ee20ab0fc9bf41c8f05fa8ceea7a08d672d7cc5")
        want = hex2bytes("8b30c5ba100f6f2e5ad1e2a742e5020491240f8eb514fe97c713c31718ad7ecd")
        @test MerkleTrees.merkle_parent(tx_hash0, tx_hash1) == want
    end
    @testset "Parent Level" begin
        hex_hashes = [
            "c117ea8ec828342f4dfb0ad6bd140e03a50720ece40169ee38bdc15d9eb64cf5",
            "c131474164b412e3406696da1ee20ab0fc9bf41c8f05fa8ceea7a08d672d7cc5",
            "f391da6ecfeed1814efae39e7fcb3838ae0b02c02ae7d0a5848a66947c0727b0",
            "3d238a92a94532b946c90e19c49351c763696cff3db400485b813aecb8a13181",
            "10092f2633be5f3ce349bf9ddbde36caa3dd10dfa0ec8106bce23acbff637dae",
            "7d37b3d54fa6a64869084bfd2e831309118b9e833610e6228adacdbd1b4ba161",
            "8118a77e542892fe15ae3fc771a4abfd2f5d5d5997544c3487ac36b5c85170fc",
            "dff6879848c2c9b62fe652720b8df5272093acfaa45a43cdb3696fe2466a3877",
            "b825c0745f46ac58f7d3759e6dc535a1fec7820377f24d4c2c6ad2cc55c0cb59",
            "95513952a04bd8992721e9b7e2937f1c04ba31e0469fbe615a78197f68f52b7c",
            "2e6d722e5e4dbdf2447ddecc9f7dabb8e299bae921c99ad5b0184cd9eb8e5908"]
        tx_hashes = [hex2bytes(x) for x in hex_hashes]
        want_hex_hashes = [
            "8b30c5ba100f6f2e5ad1e2a742e5020491240f8eb514fe97c713c31718ad7ecd",
            "7f4e6f9e224e20fda0ae4c44114237f97cd35aca38d83081c9bfd41feb907800",
            "ade48f2bbb57318cc79f3a8678febaa827599c509dce5940602e54c7733332e7",
            "68b3e2ab8182dfd646f13fdf01c335cf32476482d963f5cd94e934e6b3401069",
            "43e7274e77fbe8e5a42a8fb58f7decdb04d521f319f332d88e6b06f8e6c09e27",
            "1796cd3ca4fef00236e07b723d3ed88e1ac433acaaa21da64c4b33c946cf3d10"]
        want_tx_hashes = [hex2bytes(x) for x in want_hex_hashes]
        @test MerkleTrees.merkle_parent_level(tx_hashes) == want_tx_hashes
    end
    @testset "Root" begin
        hex_hashes = [
            "c117ea8ec828342f4dfb0ad6bd140e03a50720ece40169ee38bdc15d9eb64cf5",
            "c131474164b412e3406696da1ee20ab0fc9bf41c8f05fa8ceea7a08d672d7cc5",
            "f391da6ecfeed1814efae39e7fcb3838ae0b02c02ae7d0a5848a66947c0727b0",
            "3d238a92a94532b946c90e19c49351c763696cff3db400485b813aecb8a13181",
            "10092f2633be5f3ce349bf9ddbde36caa3dd10dfa0ec8106bce23acbff637dae",
            "7d37b3d54fa6a64869084bfd2e831309118b9e833610e6228adacdbd1b4ba161",
            "8118a77e542892fe15ae3fc771a4abfd2f5d5d5997544c3487ac36b5c85170fc",
            "dff6879848c2c9b62fe652720b8df5272093acfaa45a43cdb3696fe2466a3877",
            "b825c0745f46ac58f7d3759e6dc535a1fec7820377f24d4c2c6ad2cc55c0cb59",
            "95513952a04bd8992721e9b7e2937f1c04ba31e0469fbe615a78197f68f52b7c",
            "2e6d722e5e4dbdf2447ddecc9f7dabb8e299bae921c99ad5b0184cd9eb8e5908",
            "b13a750047bc0bdceb2473e5fe488c2596d7a7124b4e716fdd29b046ef99bbf0"]
        tx_hashes = [hex2bytes(x) for x in hex_hashes]
        want_hex_hash = "acbcab8bcc1af95d8d563b77d24c3d19b18f1486383d75a5085c4e86c86beed6"
        want_hash = hex2bytes(want_hex_hash)
        @test MerkleTrees.merkle_root(tx_hashes) == want_hash
    end
    @testset "Tree" begin
        @testset "Init" begin
            tree = MerkleTrees.MerkleTree(9)
            @test length(tree.nodes[1]) == 1
            @test length(tree.nodes[2]) == 2
            @test length(tree.nodes[3]) == 3
            @test length(tree.nodes[4]) == 5
            @test length(tree.nodes[5]) == 9
        end
        @testset "Populate Tree" begin
            hex_hashes = [
                "9745f7173ef14ee4155722d1cbf13304339fd00d900b759c6f9d58579b5765fb",
                "5573c8ede34936c29cdfdfe743f7f5fdfbd4f54ba0705259e62f39917065cb9b",
                "82a02ecbb6623b4274dfcab82b336dc017a27136e08521091e443e62582e8f05",
                "507ccae5ed9b340363a0e6d765af148be9cb1c8766ccc922f83e4ae681658308",
                "a7a4aec28e7162e1e9ef33dfa30f0bc0526e6cf4b11a576f6c5de58593898330",
                "bb6267664bd833fd9fc82582853ab144fece26b7a8a5bf328f8a059445b59add",
                "ea6d7ac1ee77fbacee58fc717b990c4fcccf1b19af43103c090f601677fd8836",
                "457743861de496c429912558a106b810b0507975a49773228aa788df40730d41",
                "7688029288efc9e9a0011c960a6ed9e5466581abf3e3a6c26ee317461add619a",
                "b1ae7f15836cb2286cdd4e2c37bf9bb7da0a2846d06867a429f654b2e7f383c9",
                "9b74f89fa3f93e71ff2c241f32945d877281a6a50a6bf94adac002980aafe5ab",
                "b3a92b5b255019bdaf754875633c2de9fec2ab03e6b8ce669d07cb5b18804638",
                "b5c0b915312b9bdaedd2b86aa2d0f8feffc73a2d37668fd9010179261e25e263",
                "c9d52c5cb1e557b92c84c52e7c4bfbce859408bedffc8a5560fd6e35e10b8800",
                "c555bc5fc3bc096df0a0c9532f07640bfb76bfe4fc1ace214b8b228a1297a4c2",
                "f9dbfafc3af3400954975da24eb325e326960a25b87fffe23eef3e7ed2fb610e"]
            tree = MerkleTrees.MerkleTree(length(hex_hashes))
            hashes = [hex2bytes(h) for h in hex_hashes]
            MerkleTrees.populate!(tree, fill(true, 31), hashes)
            root = "597c4bafe3832b17cbbabe56f878f4fc2ad0f6a402cee7fa851a9cb205f87ed1"
            @test bytes2hex(MerkleTrees.root(tree)) == root

            hex_hashes = [
                "42f6f52f17620653dcc909e58bb352e0bd4bd1381e2955d19c00959a22122b2e",
                "94c3af34b9667bf787e1c6a0a009201589755d01d02fe2877cc69b929d2418d4",
                "959428d7c48113cb9149d0566bde3d46e98cf028053c522b8fa8f735241aa953",
                "a9f27b99d5d108dede755710d4a1ffa2c74af70b4ca71726fa57d68454e609a2",
                "62af110031e29de1efcad103b3ad4bec7bdcf6cb9c9f4afdd586981795516577"]
            tree = MerkleTrees.MerkleTree(length(hex_hashes))
            hashes = [hex2bytes(h) for h in hex_hashes]
            MerkleTrees.populate!(tree, fill(true, 11), hashes)
            root = "a8e8bd023169b81bc56854137a135b97ef47a6a7237f4c6e037baed16285a5ab"
            @test bytes2hex(MerkleTrees.root(tree)) == root
        end
    end
end


text:
module GadgetronExamples

include("recon_acquisitions.jl")

import .ReconAcquisitions.reconstruct_acquisitions

include("recon_buckets.jl")

import .ReconBuckets.reconstruct_buckets
end


text:
using C2Julia
using Clang
using Test

@testset "array" begin
    tu = parse_header(joinpath(@__DIR__, "c", "array.h"), includes=[LLVM_INCLUDE])
    GC.@preserve tu begin
        root_cursor = getcursor(tu)
        func = search(root_cursor, "array")[1]
        body = children(func)[1]
        arrayinit = children(body)[1]
        @test string(translate(arrayinit)[]) == "a = [0, 1, 2, 3, 4, 5, 6, 7, 8]"
        arrayinit2 = children(body)[2]
        @test string(translate(arrayinit2)[]) == "b = [[0, 1, 2, 3], [4, 5, 6, 7]]"
        indexing = children(body)[3]
        @test string(translate(indexing)) == "(b[1])[2] = a[3]"
    end
end


text:
using LinearAlgebra, ForwardDiff, StaticArrays
using IterativeSolvers
using Plots

"""
    cones
    - nonnegative orthant (no)
        x >= 0

    - second-order (so)
        ||z1|| <= z2

    A Semismooth Newton Method for Fast, Generic Convex Programming
        https://arxiv.org/abs/1705.00772

    # todo: try backtracking linesearch for cone
        https://digital.lib.washington.edu/researchworks/bitstream/handle/1773/43279/Dueri_washington_0250E_19426.pdf?isAllowed=y&sequence=1
"""

# nonnegative orthant cone
function κ_no(z)
    max.(0.0, z)
end

# nonnegative orthant cone Jacobian
function Jκ_no(z)
    p = zero(z)
    for (i, pp) in enumerate(z)
        if pp >= 0.0
            p[i] = 1.0
        end
    end
    return Diagonal(p)
end

# second-order cone
function κ_so(z)
    z1 = z[1:end-1]
    z2 = z[end]

    z_proj = zero(z)

    if norm(z1) <= z2
        z_proj = copy(z)
    elseif norm(z1) <= -z2
        z_proj = zero(z)
    else
        a = 0.5 * (1.0 + z2 / norm(z1))
        z_proj[1:end-1] = a * z1
        z_proj[end] = a * norm(z1)
    end

    return z_proj
end

# second-order cone Jacobian
function Jκ_so(z)
    z1 = z[1:end-1]
    z2 = z[end]
    m = length(z)

    if norm(z1) <= z2
        return Diagonal(ones(m))
    elseif norm(z1) <= -z2
        return Diagonal(zeros(m))
    else
        D = zeros(m, m)
        for i = 1:m
            if i < m
                D[i, i] = 0.5 + 0.5 * z2 / norm(z1) - 0.5 * z2 * ((z1[i])^2.0) / norm(z1)^3.0
            else
                D[i, i] = 0.5
            end
            for j = 1:m
                if j > i
                    if j < m
                        D[i, j] = -0.5 * z2 * z1[i] * z1[j] / norm(z1)^3.0
                        D[j, i] = -0.5 * z2 * z1[i] * z1[j] / norm(z1)^3.0
                    elseif j == m
                        D[i, j] = 0.5 * z1[i] / norm(z1)
                        D[j, i] = 0.5 * z1[i] / norm(z1)
                    end
                end
            end
        end
        return D
    end
end

"""
    particle dynamics
    - 3D particle subject to contact forces

    - configuration: q = (x, y, z) ∈ R³
    - impact force (magnitude): n ∈ R₊
    - friction force: b ∈ R²
        - contact force: λ = (b, n) ∈ R² × R₊
        - friction coefficient: μ ∈ R₊

    Discrete Mechanics and Variational Integrators
        pg. 363
"""
struct Particle
      m # mass
      g # gravity
      μ # friction coefficient

      nq # configuration dimension
end

# mass matrix
function mass_matrix(model)
    m = model.m

    Diagonal(@SVector [m, m, m])
end

# gravity
function gravity(model, q)
    m = model.m
    g = model.g

    @SVector [0.0, 0.0, m * g]
end

# signed distance function
function signed_distance(model, q)
    q[3]
end

# contact force Jacobian
function jacobian(model, q)
    Diagonal(@SVector ones(model.nq))
end

# dynamics
function dynamics(model, q1, q2, q3, λ, h)
    nq = model.nq
    SVector{nq}(mass_matrix(model) * (2.0 * q2 - q1 - q3) / h
        - h * gravity(model, q2)
        + h * jacobian(model, q3)' * λ)
end

"""
    step particle system
        solves 1-step feasibility problem
"""
function _step(q1, q2, h;
    tol = 1.0e-8, z0_scale = 0.001, step_type = :gmres, max_iter = 100)
    """
        1-step optimization problem:
            find z
            s.t. r(z) = 0

        z = (q, n, b, ν, η)
            ν, η are slack variables for friction subproblem
    """
    function r(z)
        # system variables
        q3 = view(z, 1:3)
        n = z[4]
        b = view(z, 5:6)

        λ = [b; n]                     # contact forces
        ϕ = signed_distance(model, q3) # signed-distance function

        # friction subproblem variables
        b̄ = view(z, 5:7)
        ν = z[8]
        η = view(z, 9:11)

        # action optimality conditions
        [dynamics(model, q1, q2, q3, λ, h);
         ϕ - κ_no(ϕ - n);

         # maximum dissipation optimality conditions
         [(view(q3, 1:2) - view(q2, 1:2)) ./ h; -ν] - η;
          model.μ * n - b̄[end];
          b̄ - κ_so(b̄ - η)]
    end

    # Jacobian
    function R(z)
        # differentiate r
        _R = ForwardDiff.jacobian(r, z)

        # correct projection derivatives
        q3 = view(z, 1:3)
        ϕ = signed_distance(model, q3) # signed-distance function
        n = z[4]
        b̄ = view(z, 5:7)
        ν = z[8]
        η = view(z, 9:11)

        J_no = Jκ_no([ϕ - n])
        J_so = Jκ_so(b̄ - η)

        _R[4, 3] = 1.0 - J_no[1]
        _R[4, 4] = J_no[1]
        _R[(end-2):end, 5:11] = [(Diagonal(ones(3)) - J_so) zeros(3, 1) J_so]

        return _R
    end

    # initialize
    z = z0_scale * rand(11)
    z[1:3] = copy(q2)

    extra_iters = 0

    for i = 1:max_iter
        # compute residual, residual Jacobian
        res = r(z)

        if norm(res) < tol
            println("   iter ($i) - norm: $(norm(r(z)))")
            return z, true
        end

        jac = R(z)

        # compute step
        if step_type == :gmres
            Δ = gmres(jac, res, abstol = 1.0e-12, maxiter = i + extra_iters)
        else
            Δ = (jac' * jac + 1.0e-6 * I) \ (jac' * res) # damped least-squares direction
        end

        # line search the step direction
        iter = 0
        α = 1.0
        while norm(r(z - α * Δ))^2.0 >= (1.0 - 0.001 * α) * norm(res)^2.0 && α > 1.0e-4
            α = 0.5 * α
            # println("   α = $α")
            iter += 1
            if iter > 100
                @error "line search fail"

                return z, false
            end
        end

        if α <= 1.0e-4
            extra_iters += 1
        end

        println("   iter ($i) - norm: $(norm(r(z)))")

        # update
        z .-= α * Δ
    end

    return z, false
end

"""
    simulate
    - solves 1-step feasibility problem for T time steps
    - initial configurations: q1, q2 (note this can encode initial velocity)
    - time step: h
"""
function simulate(q1, q2, T, h;
    z0_scale = 0.0, step_type = :gmres)
    println("simulation")

    # initialize histories
    q = [q1, q2]
    n = [0.0]
    b = [zeros(2)]

    # step
    for t = 1:T
        println("   t = $t")
        z_sol, status = _step(q[end-1], q[end], h,
            z0_scale = z0_scale, step_type = step_type)

        if !status
            @error "failed step (t = $t)"
            return q, n, b
        else
            push!(q, view(z_sol, 1:3))
            push!(n, z_sol[4])
            push!(b, view(z_sol, 5:6))
        end
    end

    return q, n, b
end

# simulation setup
model = Particle(1.0, 9.81, 1.0, 3)
h = 0.05

# initial conditions
# v1 = [1.0; 1.0; 0.0]
# q1 = [0.0; 0.0; 1.0]

v1 = [-1.0; 10.0; 0.0]
q1 = [0.0; 0.0; 1.0]

v2 = v1 - gravity(model, q1) * h
q2 = q1 + 0.5 * (v1 + v2) * h

q_sol, y_sol, b_sol = simulate(q1, q2, 500, h,
    z0_scale = 0.0, step_type = :gmres)

plot(hcat(q_sol...)[3:3, :]', xlabel = "", label = "z")
plot!(h .* hcat(y_sol...)', xlabel = "", label = "n", linetype = :steppost)

plot(hcat(q_sol...)[1:2, :]', xlabel = "", label = ["x" "y"])
plot!(h * hcat(b_sol...)', label = ["b1" "b2"], linetype = :steppost)


text:
using CellFreeModelGenerationKit

# path to test metabolism file -
path_to_test_metabolism_file = "./test/data/Test-2.vff"

# need to build a model object -
build_result = build_julia_model_object(path_to_test_metabolism_file,"blank_for_now")
if (isa(build_result.value, Exception) == true)
    @show build_result.value
end
julia_model_object = build_result.value

# parse -
result = parse_vff_model_document(julia_model_object)
if (isa(result.value,Exception) == true)
    @show result.value
end
ir_dictionary = result.value

# now that we have the ir_dictionary - generate the stm
stm_gen_result = generate_stoichiometric_matrix(ir_dictionary)

max_stars_repo_name: varnerlab/CellFreeModelGenerationKit

max_issues_repo_name: varnerlab/CellFreeModelGenerationKit

max_forks_repo_name: varnerlab/CellFreeModelGenerationKit