Skip to content

Access criteria lhs/rhs values per design #554

@jonasfoerster

Description

@jonasfoerster

📝 Description of the feature

As an app developer, I want to access "lhs_value" and "rhs_value" of a criteria of an evaluated design, to show the criteria as "lhs_value <= rhs_value", instead of the internal value, similar to the "Results"-tab:

Image

With ansys-optislang-core==1.4.1 I can get only the evaluated constraint value of a design or the definition from the system:

import pathlib
from ansys.optislang.core import Optislang
from ansys.optislang.core.project_parametric import CriterionType

osl_project_file = pathlib.Path(r"path/to/project.opf")

with Optislang(project_path=osl_project_file) as osl:
    
    sensitivity = osl.project.root_system.find_nodes_by_name("Sensitivity")[0]
    for design in sensitivity.design_manager.get_designs():
        for design_variable in design.constraints:
            print(f"{design.id}, {design_variable.name}, {design_variable.value}, ({type(design_variable)})")
            
    """
    0.4, constr_r1, -4.075192241505276, (<class 'ansys.optislang.core.project_parametric.DesignVariable'>)
    0.3, constr_r1, -0.6835367115818881, (<class 'ansys.optislang.core.project_parametric.DesignVariable'>)
    0.2, constr_r1, 0.1864137676161562, (<class 'ansys.optislang.core.project_parametric.DesignVariable'>)
    0.5, constr_r1, 0.1295280305294036, (<class 'ansys.optislang.core.project_parametric.DesignVariable'>)
    0.1, constr_r1, -5.969393475372262, (<class 'ansys.optislang.core.project_parametric.DesignVariable'>)
    """

    for criterion in sensitivity.criteria_manager.get_criteria():
        if criterion.type == CriterionType.CONSTRAINT:
            print(f"{criterion.name} ({criterion.type}): {criterion.expression}, {criterion.expression_value},"
                  f" {criterion.limit_expression}, {criterion.limit_expression_value}")
            
    """
    constr_r1 (CriterionType.CONSTRAINT): r1^2, 0.0, abs(r2), 0.0
    """
        

💡 Steps for implementing the feature

No response

🔗 Useful links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions